The function returns an array that contains the time components of a Unix timestamp.

Syntax: localtime(timestamp,is_associative)

Description:

The first argument “timestamp” is Optional. It specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time.

The second argument “is_associative” is Optional. It specifies whether to return an associative or indexed array. If set to false the array returned is an indexed array. If set to true then the array returned is an associative array.

The keys of the associative array are:

* [tm_sec] – seconds
* [tm_min] – minutes
* [tm_hour] – hour
* [tm_mday] – day of the month
* [tm_mon] – month of the year (January=0)
* [tm_year] – Years since 1900
* [tm_wday] – Day of the week (Sunday=0)
* [tm_yday] – Day of the year
* [tm_isdst] – Is daylight savings time in effect

Example:
Code:

$localtime  = localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);

Output:

Array (
[0] => 6
[1] => 27
[2] => 6
[3] => 11
[4] => 3
[5] => 111
[6] => 1
[7] => 100
[8] => 0
)

Array (
[tm_sec] => 6
[tm_min] => 27
[tm_hour] => 6
[tm_mday] => 11
[tm_mon] => 3
[tm_year] => 111
[tm_wday] => 1
[tm_yday] => 100
[tm_isdst] => 0
)

eXTReMe Tracker