PHP | hrtime() Function

The hrtime() function is an inbuilt function in PHP which returns the high-resolution time of the system.

Syntax:

mixed hrtime( bool $is_num_return );

Parameter: This function accepts a single parameter as mentioned above and described below:



  • $is_num_return: It is optional parameter of Boolean type. It specifies whether it return as a single number or array. If it set to TRUE then it returns as number or as an array of integers in case of FALSE. Default value is FALSE.

Return Value: This function returns the nanoseconds or an array of integers.

Note: This function is available for PHP 7.3.0 and newer version.

Below programs illustrate the hrtime() function in PHP:

Program 1: This program sets $is_num_return to TRUE.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
print_r(hrtime(TRUE));
?>

chevron_right


Output:

149632499993800

Program 2: This program does not set $is_num_return value. It means it takes the default value.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
print_r(hrtime());
?>

chevron_right


Output:

Array ( [0] => 150389 [1] => 914027500 )

Reference: https://www.php.net/manual/en/function.hrtime.php



My Personal Notes arrow_drop_up

I am unrecognized crazy being with random thoughts

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.