PHP localtime()Functions
PHP Date/Time Reference Manual
Examples
Output local time in the form of a numeric array and an associative array:
<?php
print_r(localtime());
echo "<br><br>";
print_r(localtime(time(),true));
?>
print_r(localtime());
echo "<br><br>";
print_r(localtime(time(),true));
?>
Run Example »
Definition and Usage
The localtime() function returns the local time.
Syntax
localtime(timestamp,is_assoc);
| Parameters | Description |
|---|---|
| timestamp | Optional. Specifies a Unix timestamp. If not specifiedtimestamp, it defaults to the current local time time(). |
| is_assoc | Optional. Specifies whether to return an associative array or a numeric array. If FALSE, a numeric array is returned. If TRUE, an associative array is returned. Default is FALSE. The keys of the associative array are as follows:
|
Technical Details
| Return Value: | Returns an array containing the components of the Unix timestamp. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors. |
PHP Date/Time Reference Manual Other Extensions