PHP localtime() function

P
PHP idate() function
PHP microtime() function

What is the syntax of the localtime() function in PHP?

localtime(timestamp, is_assoc)
ParameterDescription
timestampOptional. Specifies a Unix timestamp that defaults to the current local time, time(), if no timestamp is specified
is_assocOptional. 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:[tm_sec] – seconds[tm_min] – minutes[tm_hour] – hour[tm_mday] – day of the month[tm_mon] – month of the year (January=0)[tm_year] – Years since 1900[tm_wday] – Day of the week (Sunday=0)[tm_yday] – Day of the year[tm_isdst] – Is daylight savings time in effect

Examples of the localtime() function

Example 1. In this example,

<?php
print_r(localtime());
echo "<br><br>";
print_r(localtime(time(),true));
?>
PHP idate() function
PHP microtime() function

Add comment

Tutor Network

Share this

Learn PHP from A to Z