The time_nanosleep() function delays execution of the current script for few seconds and nanoseconds.
Syntax
time_nanosleep(sec, nsec)
Parameters
sec − The number of seconds to delay the script.
nsec − The number of nanoseconds to delay the script.
Return
The time_nanosleep() function returns true on success.
Example
<?php
echo date('h:i:s') . "<br>";
// wait for 1.5 seconds
time_nanosleep(1,500000000);
echo date('h:i:s') . "<br>";
// wait for 2.5 seconds
time_nanosleep(2,500000000);
echo date('h:i:s');
?>Output
The following is the output.
02:57:04 02:57:06 02:57:08