|
time_sleep_until
Make the script sleep until the specified time
(PHP 5 >= 5.1.0)
Example 1365. A time_sleep_until() example<?php Code Examples / Notes » time_sleep_untilssnoyes
Implementation for < 5.1 or Windows users <?php if (!function_exists('time_sleep_until')) { function time_sleep_until($future) { if ($future < time()) { trigger_error("Time in past", E_USER_WARNING); return false; } sleep($future - time()); return true; } } ?> roberto
better implementation <?php if (!function_exists('time_sleep_until')) { function time_sleep_until($future) { if ($future < time()) { trigger_error("Time in past", E_USER_WARNING); return false; } usleep(($future - microtime(1))*1000000); return true; } } ?> |