Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Odczyt daty w pliku txt.
globalinfo
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 0
Dołączył: 8.10.2006

Ostrzeżenie: (0%)
-----


Witam,

Nie mogę sobie dać rady z odczytaniem daty z plku txt.

Mam taki kod

  1. $stringFromFile = fread($stateFile,filesize(myStateName));
  2. fclose($stateFile);
  3. $pos = strpos($stringFromFile, " ");
  4. echo "<br>";
  5. echo $pos;
  6. echo $stringFromFile;
  7. echo "<br>";
  8. echo substr($stringFromFile, 0, $pos);
  9. echo "<br>";
  10. $lastTime = date("Y-m-d H:i:s",substr($stringFromFile, 0, $pos));
  11. $lastReset = substr($stringFromFile, $pos+3);
  12. if (substr($stringFromFile, $pos+1,1)=="0")
  13. $lastState = "Off";
  14. else
  15. $lastState = "On";
  16. echo "Last auto-contact from the water heater was on ". $lastTime. " and the status was ". $lastState. " (Reset was ".$lastReset." Minutes ago)";


Niestety podczas wykonania otrzymuję błąd.
Poniżej wynik wyświetlony na stronie.
Cytat
13
1488113398 23 56 67
1488113398

Warning: date() expects parameter 2 to be long, string given in /....................php on line 240
Last auto-contact from the water heater was on and the status was On (Reset was 56 67 Minutes ago)

Wartość jaka wpisana jest w pliku
Cytat
1488113398 23 56 67


Nie bardzo wiem jak to ugryźć sciana.gif

Ten post edytował globalinfo 26.02.2017, 14:37:21
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 02:55