PHP localtime() Function
Example
Print local time as an indexed and as an associative array:
<?php
print_r(localtime());
echo "<br><br>";
print_r(localtime(time(),true));
?>
Try it Yourself »
Definition and Usage
The localtime() function returns the local time.
Syntax
localtime(timestamp, is_assoc)
Parameter Values
Parameter | Description |
---|---|
timestamp | Optional. Specifies a Unix timestamp that defaults to the current local time, time(), if no timestamp is specified |
is_assoc | Optional. Specifies whether to return an associative or indexed array. FALSE = the array returned is an indexed array. TRUE = the array returned is an associative array. FALSE is default.
The keys of the associative array are:
|
Technical Details
Return Value: | Returns an array that contains the components of a Unix timestamp |
---|---|
PHP Version: | 4+ |
PHP Changelog: | PHP 5.1: Now issues E_STRICT and E_NOTICE time zone errors |
❮ PHP Date/Time Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.