PHP gettimeofday()Functions

PHP Date/TimePHP Date/Time Reference Manual

Examples

Return the current time:

<?php
// Print the array from gettimeofday()
print_r(gettimeofday());

// Print the float from gettimeofday()
echo gettimeofday(true);
?>

Run example »

Definition and Usage

The gettimeofday() function returns the current time.

Syntax

gettimeofday(return_float);

Parameters Description
return_float Optional. When set to TRUE, a float is returned instead of an array. Default is FALSE.

Technical Details

Return value: By default, returns an associative array with the following array keys: R
  • [sec] - Seconds since the Unix Epoch
  • [usec] - Microseconds
  • [minuteswest] - Minutes west of Greenwich
  • [dsttime] - Type of daylight saving time correction
Ifreturn_floatthe parameter is set to true, a float is returned.
PHP Version: 4+
Changelog: PHP 5.1.0: Added thereturn_floatparameter.


PHP Date/TimePHP Date/Time Reference Manual Other Extensions