time_sleep_until
Description
The time_sleep_until of Miscellaneous for PHP make the script sleep until the specified time.
Syntax
time_sleep_until ( float $timestamp ) : bool
Parameters
timestamp
The timestamp when the script should wake.
Return
Returns TRUE on success or FALSE on failure.
Examples
1
<? echo date('h:i:s') . PHP_EOL; // 1 second after now $timestamp = time() + 1; time_sleep_until($timestamp); echo date('h:i:s');
06:28:37 06:28:38
2
<? echo date('h:i:s') . PHP_EOL; // 1 second after now $timestamp = strtotime("1 second"); time_sleep_until($timestamp); echo date('h:i:s');
06:28:39 06:28:40
3
<? // 1 second before now $timestamp = time() - 1; // returns false and generates a warning $bool = time_sleep_until($timestamp); var_dump($bool);
bool(false)
4
<? // 1 second after now $timestamp = time() + 1; $bool = time_sleep_until($timestamp); var_dump($bool);
bool(true)