I`m using the php command microTime(true) to retrieve time from the server.
I would like to fire off an event every time an complete second is reached, I need accuracy of microsecomds to determine when a complete second is reached.
This is the code i have so far:
$time_start = microtime(true);
while($someValue){
if(microtime(true)==time()){
echo "<p>".microtime(true)."</p>";
echo "<p>".time()."</p>";
}
//sleep for one microsecond
usleep(1);
}
Can someone help or explain to me how to get this right?
Why not using usleep only once?
Are you sure that it will be less precise? I don’t see how…