In this article, you will learn how to get the current time of the day. The PHP gettimeofday() function returns the current time of the day.
Note: This function returns the current time of the day according the server on which the PHP script is running.
What is the syntax of the gettimeofday() function in PHP?
gettimeofday(return_float)
Parameter | Description |
---|---|
return_float | Optional. When set to TRUE, a float instead of an array is returned. Default is FALSE |
Example of the gettimeofday() function
Example 1. In this example, we simply return the current time. First we print the array from gettimeofday() method and then print the float from gettimeofday() method.
<?php
print_r(gettimeofday());
echo gettimeofday(true);
?>