(PHP 4, PHP 5, PHP 7)
localtime — Get the local time
localtime ([ int|null $timestamp = null [, bool $associative = false ]] ) : array
The localtime() function returns an array identical to that of the structure returned by the C function call.
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
If set to false
or not supplied then the array is returned as a regular, numerically indexed array. If the argument is set to true
then localtime() returns an associative array containing all the different elements of the structure returned by the C function call to localtime. The names of the different keys of the associative array are as follows:
0
to 59
0
to 59
0
to 23
1
to 31
0
(Jan) to 11
(Dec) 0
(Sun) to 6
(Sat) 0
to 365
0
if not, negative if unknown. Every call to a date/time function will generate a E_NOTICE
if the time zone is not valid, and/or a E_STRICT
or E_WARNING
message if using the system settings or the TZ environment variable. See also date_default_timezone_set()
Version | Description |
---|---|
8.0.0 | timestamp is nullable now. |
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/function.localtime.php