time_sleep_until()

time_sleep_until() — Make the script sleep until the specified time.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

time_sleep_until(float $timestamp): bool

Parameters

ParameterTypeWhat it takes
$timestampfloatThe timestamp when the script should wake.

Return value

Returns true on success or false on failure.

Example

A runnable snippet:

//returns false and generates a warning var_dump(time_sleep_until(time()-1)); // may only work on faster computers, will sleep up to 0.2 seconds var_dump(time_sleep_until(microtime(true)+0.2));

See also

sleep(), usleep(), time_nanosleep(), set_time_limit()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page time_sleep_until() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.