localtime
Description
The localtime of Date / Time for PHP get the local time.
Syntax
localtime(?int $timestamp = null, bool $associative = false): array
Parameters
timestamp
The optional timestamp parameter is an int Unix timestamp that defaults to the current local time if timestamp is omitted or null. In other words, it defaults to the value of time().
associative
Determines whether the function should return a regular, numerically indexed array, or an associative one.
Return
If associative is set to false or not supplied then the array is returned as a regular, numerically indexed array. If associative is set to true then localtime() returns an associative array containing the elements of the structure returned by the C function call to localtime. The keys of the associative array are as follows:
"tm_sec" | seconds, 0 to 59 |
"tm_min" | minutes, 0 to 59 |
"tm_hour" | hours, 0 to 23 |
"tm_mday" | day of the month, 1 to 31 |
"tm_mon" | month of the year, 0 (Jan) to 11 (Dec) |
"tm_year" | years since 1900 |
"tm_wday" | day of the week, 0 (Sun) to 6 (Sat) |
"tm_yday" | day of the year, 0 to 365 |
"tm_isdst" | is daylight savings time in effect? Positive if yes, 0 if not, negative if unknown. |
Examples
1 · void
<? $return = localtime(); print_r($return); ?>
Array ( [0] => 46 [1] => 57 [2] => 10 [3] => 7 [4] => 9 [5] => 124 [6] => 1 [7] => 280 [8] => 0 )
2 · timestamp
<? $timestamp = time(); $return = localtime($timestamp); print_r($return); ?>
Array ( [0] => 46 [1] => 57 [2] => 10 [3] => 7 [4] => 9 [5] => 124 [6] => 1 [7] => 280 [8] => 0 )
3 · associative
<? $timestamp = time(); $associative = true; $return = localtime($timestamp, $associative); print_r($return); ?>
Array ( [tm_sec] => 46 [tm_min] => 57 [tm_hour] => 10 [tm_mday] => 7 [tm_mon] => 9 [tm_year] => 124 [tm_wday] => 1 [tm_yday] => 280 [tm_isdst] => 0 )
Links
Date / Time
- checkdate
- date
- date_add
- date_create
- date_create_from_format
- date_create_immutable
- date_create_immutable_from_format
- date_date_set
- date_default_timezone_get
- date_default_timezone_set
- date_diff
- date_format
- date_get_last_errors
- date_interval_create_from_date_string
- date_interval_format
- date_isodate_set
- date_modify
- date_offset_get
- date_parse
- date_parse_from_format
- date_sub
- date_sun_info
- date_sunrise
- date_sunset
- date_time_set
- date_timestamp_get
- date_timestamp_set
- date_timezone_get
- date_timezone_set
- getdate
- gettimeofday
- gmdate
- gmmktime
- gmstrftime
- idate
- microtime
- mktime
- strftime
- strptime
- strtotime
- time
- timezone_abbreviations_list
- timezone_identifiers_list
- timezone_location_get
- timezone_name_from_abbr
- timezone_name_get
- timezone_offset_get
- timezone_open
- timezone_transitions_get
- timezone_version_get