The following example of localtime is used for resulting a local timestamp.
The following example of localtime is used for resulting a local timestamp.
localtime() returns an array containing the time components of a Unix timestamp. It returns an array identical to that of the structure returned by the C function call.
Syntax of localtime() Function PHP
localtime(timestamp,is_associative)
Parameter & Description of localtime() Function PHP
timestamp - timestamp is optional parameter. It specifies the date or time to be formatted, it returns the local time if it is not formatted.
is_associative - is_associative is optional that 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:
Example: Example without and with associative arrays:
<?php
print_r(localtime());
echo("<br /><br />");
print_r(localtime(time(),true));
?>
The output of the code above could be:
Array
(
[0] => 15
[1] => 23
[2] => 09
[3] => 14
[4] => 12
[5] => 115
[6] => 5
[7] => 17
[8] => 4
)
Array
(
[tm_sec] => 15
[tm_min] => 23
[tm_hour] => 09
[tm_mday] => 14
[tm_mon] => 12
[tm_year] => 115
[tm_wday] => 5
[tm_yday] => 17
[tm_isdst] => 4
)