When registering some data with microtime () (using PHP 5), I came across some values ββthat are slightly out of phase with respect to the timestamp of my log file, so I just tried to compare the output of time () and microtime () with a simple script (you can simply compress it here to limit data output):
<?php for($i = 0; $i < 500; $i++) { $microtime = microtime(); $time = time(); list($usec, $sec) = explode(" ", $microtime); if ((int)$sec > $time) { echo $time . ' : ' . $microtime . '<br>'; } usleep(50000); } ?>
Now that $ microtime is declared before $ time, I expect it to be smaller and nothing should be output; however, this is obviously not the case, and from time to time, $ time is less than the seconds returned from microtime (), as in this example the (truncated) output:
1344536674 : 0.15545100 1344536675 1344536675 : 0.15553900 1344536676 1344536676 : 0.15961000 1344536677 1344536677 : 0.16758900 1344536678
Now this is just a small gap; however, I have seen some series where the difference is (pretty) more than a second ... so how is this possible?
source share