PHP | gettimeofday() Function Last Updated : 04 Sep, 2018 Comments Improve Suggest changes Like Article Like Report The gettimeofday() function is an inbuilt function in PHP which is used to return the current time. It is an interface to Unix system call gettimeofday(2). It returns an associative array containing the data returned from the system call. The float option is sent as a parameter to the gettimeofday() function and returns an associative array containing the current time. Syntax: gettimeofday( $return_float ) Parameters: This function accepts single parameter $return_float which is optional. This parameter is used to set to TRUE, then it returns a float value instead of an array. Return Value: It returns an associative array containing the current time. If $return_float parameter is set then it return float value. The associative array consists of the following array keys: sec: It is used to specify the seconds since the Unix Epoch. usec: It is used to specify the microseconds. minuteswest: It is used to specify the minutes west of Greenwich. dsttime: It is used to specify the type of dst correction. Exception: The $return_float parameter was added since PHP 5.1.0 version. Below programs illustrate the gettimeofday() function in PHP: Program 1: php <?php // Displaying the current time // as an associative array echo ("Current time is: "); print_r(gettimeofday()); ?> Output: Current time is: Array ( [sec] => 1536040360 [usec] => 178383 [minuteswest] => 0 [dsttime] => 0 ) Program 2: php <?php // Displaying the current time // as a float value echo ("Current time is: "); print_r(gettimeofday(true)); ?> Output: Current time is: 1536040361.1613 Related Articles: PHP | gmstrftime() Function PHP | getdate() Function PHP | gmmktime() Function Reference: http://php.net/manual/en/function.gettimeofday.php Comment More infoAdvertise with us Next Article PHP | gettimeofday() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | getdate() Function The getdate() function is an inbuilt function in PHP which is used to get date/time information of the current local date/time. Syntax: getdate($timestamp) Parameters: The getdate() function accepts one parameter and it is described below: $timestamp: It is an optional parameter which specifies an i 2 min read PHP | gmstrftime() Function The gmstrftime() function is an inbuilt function in PHP which is used to format a GMT/UTC time/date according to local settings. The gmstrftime() function in PHP behaves in the same way as strftime() except that the time returned by the gmstrftime() function is Greenwich Mean Time (GMT). The $format 2 min read PHP | gmmktime() Function The gmmktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a GMT date. The $hour, $minute, $second, $month, $day, $year and $is_dst are sent as parameters to the gmmktime() function and it returns an integer Unix timestamp on success or False on error. Synta 2 min read PHP | mktime() Function The mktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a date. The timestamp returns a long integer containing the number of seconds between the Unix Epoch (January 1, 1970, 00:00:00 GMT) and the time specified. The hour, minute, second, month, day and yea 2 min read PHP | gmdate() Function The gmdate() is an inbuilt function in PHP which is used to format a GMT/UTC date and time and return the formatted date strings. It is similar to the date() function but it returns the time in Greenwich Mean Time (GMT). Syntax: string gmdate ( $format, $timestamp ) Parameters: The gmdate() function 2 min read PHP | hrtime() Function The hrtime() function is an inbuilt function in PHP which returns the high-resolution time of the system. Syntax: mixed hrtime( bool $is_num_return ); Parameter: This function accepts a single parameter as mentioned above and described below: $is_num_return: It is optional parameter of Boolean type. 1 min read PHP | IntlCalendar getTime() Function The IntlCalendar::getTime() function is an inbuilt function in PHP which is used to return the time currently represented by the object. The time is expressed in terms of milliseconds since the epoch. Syntax: Object oriented style float IntlCalendar::getTime( void ) Procedural style float intlcal_ge 1 min read PHP | IntlCalendar get() Function The IntlCalendar::get() function is an inbuilt function in PHP which is used to get the value for a specific field. Syntax: Object oriented style int IntlCalendar::get( int $field ) Procedural style int intlcal_get( IntlCalendar $cal, int $field ) Parameters: This function uses two parameters as men 2 min read PHP | idate() Function The idate() function is an inbuilt function in PHP which is used to format a local time/date as an integer. The $format and $timestamp are sent as parameters to the idate() function and it returns an integer formatted according to the specified format using the given timestamp. Unlike the function d 2 min read PHP | IntlCalendar getTimeZone() Function The IntlCalendar::getTimeZone() function is an inbuilt function in PHP which is used to return the timezone object associated with this calendar. Syntax: Object oriented style IntlTimeZone IntlCalendar::getTimeZone( void ) Procedural style IntlTimeZone intlcal_get_time_zone( IntlCalendar $cal ) Para 2 min read Like