PHP: gettimeofday() function
PHP: Get current time
The gettimeofday() function is used to get current time information.
Version:
(PHP 4 and above)
Syntax:
gettimeofday(return_float)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
return_float | When setting to TRUE, a float instead of an array is returned. | Optional | Float |
Return value:
An associative array. If return_float is set, then a float is returned.
Array elements details:
Key | Description |
---|---|
sec | seconds since the Unix Epoch. |
usec | Microseconds. |
minuteswest | Minutes west of Greenwich. |
dsttime | Type of dst correction |
Example:
<?php
print_r(gettimeofday());
?>
Output:
Array ([sec] => 1281420398 [usec] => 985536 [minuteswest] => 0 [dsttime] => 0 )
Note : Since the current time is not static, therefore the output may vary.
View the example in the browser
See also
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/gettimeofday.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics