PHP time_nanosleep() Function

Definition and Usage

The time_nanosleep() function delays the execution of the code for several seconds and nanoseconds.

Syntax

time_nanosleep(seconds,nanoseconds)
Parameters Description
seconds Required. Must be a positive integer.
nanoseconds Required. Must be a positive integer less than one billion.

Description

Delays the execution of the program for the specified seconds and nanoseconds Numbers.

Return value

Returns TRUE if successful, FALSE if failed

If the delay is interrupted by a signal, it will return an associative array with the following components:

  • seconds - The remaining seconds in the delay
  • nanoseconds - The remaining nanoseconds in the delay

Tips and Comments

Note:This function is not implemented on the Windows platform.

Example

<?php
if (time_nanosleep(3,500000000) === true)
  {
  echo "Pause for 3 and a half seconds";
  }
?>