localtimeDescriptionlocaltime() executes the system's localtime() system call and returns its results in a PHP array. If the associative parameter given is TRUE, the returned array will be an associative array with the key names from the following table; otherwise, the returned array will be indexed starting from 0. If no argument is given for associative , the default is FALSE. The following table describes the elements of the returned array.
ExampleExample 204. Get the time components in an array /* When executed at 22:52 April 19, 2001, the following * code produced this output: * * Indexed array of the current time: * Array * ( * [0] => 26 * [1] => 52 * [2] => 22 * [3] => 19 * [4] => 3 * [5] => 101 * [6] => 4 * [7] => 108 * [8] => 1 * ) * Associative array of 2 PM April 30 1981: * Array * ( * [tm_sec] => 0 * [tm_min] => 0 * [tm_hour] => 14 * [tm_mday] => 30 * [tm_mon] => 3 * [tm_year] => 81 * [tm_wday] => 4 * [tm_yday] => 119 * [tm_isdst] => 1 * ) */ echo "Indexed array of the current time:\n"; $time_array = localtime(time()); print_r($time_array); echo "Associative array of 2 PM April 30 1981:\n"; $time_array = localtime(mktime(14, 0, 0, 4, 30, 81), 1); print_r($time_array);
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|