PHP: localtime() function
Description
The localtime() function is used to get the localtime.
Version:
(PHP 4 and above)
Syntax:
localtime(timestamp, is_associative)
Parameters:
Name | Description | Required/ Optional | Type |
---|---|---|---|
timestamp | The timestamp parameter is a Unix timestamp.If no timestamp is specified, it uses the current local time. | Optional | Integer |
is_associative | If the argument is set to true the array returned an
indexed array otherwise the array returned is an
associative array. The following list describes the elements of the returned array. tm_sec - seconds tm_min - minutes tm_hour - hour tm_mday - the day of the month. "tm_mon" - month of the year, starting with 0 for January "tm_year" - Years since 1900 "tm_wday" - Day of the week "tm_yday" - Day of the year "tm_isdst" - Is daylight savings time in effect |
Optional | Boolean |
Return value:
An array.
Value Type: Array.
Example:
<?php
print_r(localtime(time(),true));
echo '<br />';
print_r(localtime());
?>
Sample Output:
Array ( [tm_sec] => 52 [tm_min] => 20 [tm_hour] => 7 [tm_mday] => 19 [tm_mon] => 0 [tm_year] => 111 [tm_wday] => 3 [tm_yday] => 18 [tm_isdst] => 0 ) Array ( [0] => 52 [1] => 20 [2] => 7 [3] => 19 [4] => 0 [5] => 111 [6] => 3 [7] => 18 [8] => 0 )
View the example in the browser
See also
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics