Time moving backwards?

for($i=0;$i<10000;$i++) {
$start = microtime(true);
for($k=0;$k<1000;$k++) { } // Do some work
$delta = microtime(true) - $start;
if($delta < 0) {
print “Negative delta: $delta

When running this PHP5 code about 99% of the time $delta is a positive as it should be. But some times I get a negative $delta! How can this be? It’s usually around -1.8 seconds.

Can anyone explain why this is happening?


Hmm, interesting problem. I did a ping test that returned some warnings. It appears that it could be related. I googled the errors below. I have included the errors and a possible google answer.

Warning: time of day goes back (-1786707us), taking countermeasures.
Warning: time of day goes back (-1786534us), taking countermeasures.

,The reason it says time of day goest back, is your system clock is not
synced to the rest of the network. Try the command ntpdate. I had to
download the new version for it to recognize any time servers. (try doing a
search on google for ntpdate servers). Also if you cant ping your other
machines, take a look at your routing tables. Mine likes to reset
spontaneously. If it has reset then: route add default gw