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'); ?>
03:01:04 03:01:05
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'); ?>
03:01:05 03:01:06
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)