time comparison off by 1 minute ???
Posted: Wed Dec 27, 2006 4:39 pm
ok so i am coding something that shows minutes remaining for a server to do something.
The code seems to work fine, except that for the fact that it is always 1 minute off for some reason. Any help would be greatly appreciated. I did a ghetto fix of:
so here is the code:
output of script =
start: 04:37:13
stop: 04:35:00
diff: 57
Servers in Maintenance Mode
Name -----------------StartTime-------------------------- EndTime---------- Time Remaining----------Remove
BATMAN----------Dec 27 2006 4:20PM-------- Dec 27 2006 4:35PM----------58----------------------Button
The code seems to work fine, except that for the fact that it is always 1 minute off for some reason. Any help would be greatly appreciated. I did a ghetto fix of:
Code: Select all
$diff_time=($stop_time -$start_time)+1;Code: Select all
$start_time=time();
$stop_time=strtotime($val); // value pulled from sql database
echo "<br>start: ".date('h:i:s',$start_time);
echo "<br>stop: ".date('h:i:s',$stop_time);
$diff_time=date('i',$stop_time) - date('i',$start_time);
echo "<br>diff: ".$diff_time;
if ($diff_time < 0) // added this time to account for negitive number. But still off by 1 minute.
{
$diff_time='0';
}
$diff_time=$diff_time;start: 04:37:13
stop: 04:35:00
diff: 57
Servers in Maintenance Mode
Name -----------------StartTime-------------------------- EndTime---------- Time Remaining----------Remove
BATMAN----------Dec 27 2006 4:20PM-------- Dec 27 2006 4:35PM----------58----------------------Button