Latest web development tutorials

PHP gettimeofday () function

PHP Date / Time PHP Date / Time Reference Manual

Examples

Returns the current time:

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

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

Running instance »

Definition and Usage

gettimeofday () function returns the current time.

grammar

gettimeofday( return_float);

参数 描述
return_float 可选。当设置为 TRUE 时,返回一个浮点数,而不是一个数组。默认是 FALSE。

technical details

return value: Default returns an associative array, the array with the following keys: R
  • [Sec] - Unix seconds since the epoch
  • [Usec] - microseconds
  • [Minuteswest] - minutes west of Greenwich
  • [Dsttime] - Fixed daylight saving time type
If return_float parameter is set to true, it returns a float.
PHP version: 4+
Update log: PHP 5.1.0: Added return_float parameters.


PHP Date / Time PHP Date / Time Reference Manual