Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

gettimeofday()

Example

Return the current time.

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

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

Definition and Usage

The gettimeofday() function retrieves the current time.

Syntax

gettimeofday(return_float)

Parameter Values

 

Parameter

Description

return_float

Optional. If set to TRUE, the function returns a float instead of an array. The default is FALSE.

Technical Details

Return Value:

By default, the function returns an associative array with the following keys:

 

[sec]: Seconds since the Unix Epoch

[usec]: Microseconds

[minuteswest]: Minutes west of Greenwich

[dsttime]: Type of DST correction

If the return_float parameter is set to true, the function returns a float instead.

PHP Version:

4+

Changelog:

PHP 5.1.0: Introduced the return_float parameter.