Home >>PHP Date Time Functions >PHP gettimeofday() Function
PHP gettimeofday() function is used to return the current time. It returns an associative array containing the data returned from the system call, that is the current time. It accepts only a single parameter $return_float which is optional. It returns an associative array containing the current time and return float value if $return_float parameter is set.
Syntax:
gettimeofday(return_float);
Parameter | Description |
---|---|
return_float | This is an optional parameter. If it is set to TRUE, a float instead of an array is returned. |
Here is an example of getdateofday() function in PHP:
<html> <body> <pre> <?php print_r(gettimeofday()); ?> </pre> </body> </html>
Array ( [sec] => 1580546770 [usec] => 564597 [minuteswest] => 0 [dsttime] => 0 )
Example 2:
<html> <body> <?php echo gettimeofday(true); ?> </body> </html>