PHP | time_sleep_until( ) Function Last Updated : 21 Jun, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The time_sleep_until() function in PHP is an inbuilt function which is used to delay execution of the current script until the specified time. The time_sleep_until( ) function accepts timestamp as a parameter and this timestamp denotes when the script should wake. The time_sleep_until( ) function returns TRUE on success or FALSE on failure. Syntax: time_sleep_until(timestamp) Parameters Used: The time_sleep_until() function in PHP accepts one parameter timestamp . It is a mandatory parameter which specifies the time to wake. Return Value: It returns TRUE on success or FALSE on failure. Errors And Exceptions: If the specified timestamp is in the past, this function will generate an E_WARNING. All signals are delivered after the script wakes up. This function throws an error if the specified number is negative. Examples: Input : echo date('h:i:s'); time_sleep_until(time()+5); echo date('h:i:s'); Output: 07:23:26 07:23:31 Input : echo date('h:i:s'); time_sleep_until(time()+ rand(1, 3)); echo date('h:i:s'); Output : 07:21:55 07:21:57 Below programs illustrate the time_sleep_until() function: Program 1: php <?php // displaying time echo date('h:i:s'); // delaying execution of script for 5 seconds time_sleep_until(time()+5); // displaying time again echo ("\n"); echo date('h:i:s'); ?> Output: 06:50:04 06:50:08 Program 2: php <?php // displaying time echo date('h:i:s'); // using rand() function to randomly choose a // value and delay execution of the script time_sleep_until(time()+ rand(1, 3)); // displaying time again echo ("\n"); echo date('h:i:s'); ?> Output: 06:50:14 06:50:15 Program 3: php <?php // delaying execution of script with negative time time_sleep_until(time()-2); // displaying time again echo ("\n"); echo date('h:i:s'); ?> Output: false Reference : http://php.net/manual/en/function.time-sleep-until.php Comment More infoAdvertise with us Next Article PHP | time_sleep_until( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | sleep( ) Function The sleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds. The sleep( ) function accepts seconds as a parameter and returns TRUE on success or FALSE on failure. If the call is interrupted by a signal, sleep() funct 2 min read PHP | strptime() Function The strptime() function is an inbuilt function in PHP which is used to parse a time / date generated with strftime() function. The date and format are sent as a parameter to the strptime() function and it returns an array on success or False on failure. The array returned by the strptime() function 2 min read PHP | usleep( ) Function The usleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for specific microseconds. It is similar to the sleep() function which delays execution of the current script for a specified number of seconds, unlike the usleep() function which delays th 2 min read PHP | time() Function The time() function is a built-in function in PHP which returns the current time measured in the number of seconds since the Unix Epoch. The number of seconds can be converted to the current date using date() function in PHP. Syntax: int time() Parameter: This function does not accepts any parameter 2 min read PHP | date_time_set() Function The date_time_set() function is an inbuilt function in PHP which is used to sets the time. This function resets the current time of the DateTime object to a different time. Syntax: Procedural style: date_time_set( $object, $hour, $minute, $second, $microseconds ) Object oriented style: DateTime::set 2 min read Like