The error is in this part:
Code:
while (!feof($f))
{
$x=fgetc($f);
$twotime=$x;
}
change it to:
Code:
$twotime = fgets($f);
Also why use all the date() functions if u can just do 1 time();
this does the exact same as your code but much easier
Code:
$file = "time.txt";
$time = time(); //UNIX timestamp, amount of seconds since 1-1-1970.
if(($f = @fopen($file, "r")) == false) { //Open the file.
if(!file_exists($file)) { //If it doesnt exist, make it.
$f = fopen($file, "w");
$oldtime = 0;
}
else //If it doesn't open.
exit("Unable to open the file");
}
else
$oldtime = fgets($f); //Get content.
fclose($f);
$f = fopen($file, "w");
fwrite($f, $time);
fclose($f);
$timesub = $time - $oldtime;
echo $time."</br>".$oldtime."</br>".$timesub;