PHP | time_nanosleep( ) Function Last Updated : 03 Jul, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The time_nanosleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds and nanoseconds. The time_nanosleep() function accepts seconds and nanoseconds as parameters and returns TRUE on success or FALSE on failure. If the delay is interrupted by a signal, an associative array is returned with the following components: seconds: It denotes the number of seconds remaining in the delay. nanoseconds: It denotes the number of nanoseconds remaining in the delay. Syntax: time_nanosleep(seconds, nanoseconds) Parameters Used: The time_nanosleep() function in PHP accepts two parameters. seconds : It is a mandatory parameter which specifies the number of seconds. nanoseconds : It is a mandatory parameter which specifies the number of nanoseconds. Return Value: It returns TRUE on success or FALSE on failure.If the delay is interrupted by a signal, an associative array is returned with the remaining seconds and nanoseconds. Errors And Exceptions: The value of nanoseconds passed as parameter must be less than 1, 000, 000, 000. The value of seconds passed as parameter should be non-negative. Below programs illustrate the time_nanosleep() function: Program 1: php <?php // displaying time if (time_nanosleep(2, 500000000) === true) { echo "Execution delayed for two and half a second"; } else { echo "No delay in Execution"; } ?> Output: Execution delayed for two and half a second Program 2: php <?php // displaying time echo date('h:i:s'); // delaying execution of the script for 2 seconds and half a second time_nanosleep(2, 500000000); // displaying time again echo ("\n"); echo date('h:i:s'); ?> Output: 06:45:15 06:45:18 Reference : http://php.net/manual/en/function.time-nanosleep.php Comment More infoAdvertise with us Next Article PHP | time_nanosleep( ) 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 | 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 | timezone_open() Function The timezone_open() function is an inbuilt function in PHP which is used to create a new DateTimeZone object. The timezone_open() function accepts the timezone as a parameter and returns the DateTimeZone object on success or False on failure. Syntax: timezone_open( $timezone ) Parameters: This funct 2 min read PHP | timezone_name_get() Function The timezone_name_get() function is an inbuilt function in PHP which is used to return the name of the timezone. The date time object is sent as a parameter to the timezone_name_get() function and it returns the name of the timezone on success or False on failure. Syntax: string timezone_name_get( $ 2 min read PHP IntlCalendar setTime() Function PHP IntlCalendar::setTime() function is an inbuilt function in PHP which is used to set the calendar time object in terms of milliseconds since the epoch. The calendar time instant is represented by the float and its value should be an integer number of milliseconds since the epoch (1 Jan 1970 00:00 2 min read PHP | strftime() Function The strftime() function is an inbuilt function in PHP that formats local time or date according to locale settings i.e. it formats local time or date for location set for it of a place. Syntax: strftime( $format, $timestamp ) Parameters: This function accept two parameters as mentioned above and des 5 min read Like