Monday, 12 August 2013

how to calculate time left using string minus another string?

how to calculate time left using string minus another string?

i have lets say a $value = 5; and the valnue means 5 minutes, and i have a
file saved on the server and getting modified a lot called check.txt i
want a code to do a calculation of if timenow - timemodification of file
<= 0 in H:i:s from the main $value of 5 minutes then continue, else echo
please wait minutes left from the time now - filetimemodification of the
main value of 5 minutes = $timeleft in m:s format.
i'm testing on the current code but i keep getting a value of -1376352747
my code which is know is bad :) is
$filename = 'check.txt';
$time = date("H:i:s");
$time = str_replace("00", "24", $time);
$filemodtime = filemtime($filename);
$timeleft = $time - $filemodtime;
$h = explode(':', $time);
$h = $h[0];
$h = str_replace("00", "24", $h);
$m = explode(':', $time);
$m = $m[1];
$s = explode(':', $time);
$s = $s[2];
$hms = ("$h:$m:$s");
if (count($filemodtime - $time) <= 0) {
echo "you can continue";
}
else {
echo " please wait $timeleft";
}
thanks in advance

No comments:

Post a Comment