Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

PHP gettimeofday() Function: Usage, Parameters, Return Values, and Example

PHP gettimeofday() Function: Usage, Parameters, Return Values, and Example

The PHP gettimeofday() function provides access to the system's current time, returning either an associative array with seconds, microseconds, timezone offset, and DST information or a floating‑point timestamp when the optional return_float parameter is set to true.

The gettimeofday() function in PHP provides access to the system's gettimeofday(2) call, returning either an associative array with time components or a float when the optional $return_float parameter is set to true.

When called without arguments, it returns an array containing the keys "sec" (seconds since the Unix epoch), "usec" (microseconds), "minuteswest" (minutes west of Greenwich), and "dsttime" (daylight‑saving time type).

If $return_float is true, the function returns a single floating‑point number representing the current Unix timestamp with microsecond precision.

Example usage:

<?php
print_r(gettimeofday());
echo gettimeofday(true);
?>

Typical output of the array form looks like:

Array (
    [sec] => 1073504408
    [usec] => 238215
    [minuteswest] => 0
    [dsttime] => 1
)
1073504408.23910
About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article
PHPtimegettimeofday

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion