When I use the time() function to capture the time, sleep(5) seconds, and capture the time again, the difference between between the two times is 1 hour and 5 seconds.
- Code: Select all
<?php
$start_time = time();
$format = "%T";
$stime = strftime($format, $start_time);
print "Start Time: $stime<br>";
// do something that takes time
print "<br>doing something<br><br>";
sleep(5);
$stop_time = time();
$stime = strftime($format, $stop_time);
print "Stop Time: $stime<br>";
$dif_time = $stop_time - $start_time;
$strtime = strftime("%T", $dif_time);
print "Difference: $strtime <br>";
?>
results in:
Start Time: 22:42:46
doing something
Stop Time: 22:42:51
Difference: 01:00:05