Output the local time as a numeric array and an associative array:
<?phpprint_r(localtime());echo "<br><br>";print_r(localtime(time(),true));?>The localtime() function returns the local time.
localtime( timestamp,is_assoc);
parameter | describe |
---|---|
timestamp | Optional. Specifies the Unix timestamp. If timestamp is not specified, it defaults to the current local time time(). |
is_assoc | Optional. Specifies whether to return an associative array or a numeric array. If FALSE, returns a numeric array. If TRUE, returns an associative array. Default is FALSE. The key names of the associative array are as follows: [tm_sec] - number of seconds [tm_min] - number of minutes [tm_hour] - hour [tm_mday] - Day of the month [tm_mon] - Month in year, starting from 0 for January [tm_year] - year, starting from 1900 [tm_wday] - day of the week (Sunday=0) [tm_yday] - Day of the year [tm_isdst] - Whether daylight saving time is currently in effect |
Return value: | Returns an array containing the Unix timestamp components. |
---|---|
PHP version: | 4+ |
Update log: | PHP 5.1.0: Added E_STRICT and E_NOTICE time zone errors. |