PHP localtime() Function
What is a local time Function?
Explanation
The "localtime()" function is used return an array that contains the locale time.
Syntax:
localtime(timestamp,is_associative)
In the above syntax the parameters for the function "is_associative" returns a value in an associative array the different elements of localtime, "timestamp" is an optional field, when not specified it takes the current local time.
Example :
<?php
$localtime = localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);
?>
Result :
Array
(
[0] => 28
[1] => 35
[2] => 13
[3] => 25
[4] => 0
[5] => 106
[6] => 3
[7] => 24
[8] => 0
)
Array
(
[tm_sec] => 28
[tm_min] => 35
[tm_hour] => 13
[tm_mday] => 25
[tm_mon] => 0
[tm_year] => 106
[tm_wday] => 3
[tm_yday] => 24
[tm_isdst] => 0
)
In the above example the localtime() function first returns the values without specifying the fields, in the second output the array is specific to what it returns, since time() is used.
Note :
(PHP 4, PHP 5)