array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.localtime.php', 1 => 'localtime', 2 => 'Get the local time', ), 'up' => array ( 0 => 'ref.datetime.php', 1 => 'Функції Дати/часу', ), 'prev' => array ( 0 => 'function.idate.php', 1 => 'idate', ), 'next' => array ( 0 => 'function.microtime.php', 1 => 'microtime', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/datetime/functions/localtime.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

localtime

(PHP 4, PHP 5, PHP 7, PHP 8)

localtimeGet the local time

Опис

localtime(?int $timestamp = null, bool $associative = false): array

The localtime() function returns an array identical to that of the structure returned by the C function call.

Параметри

timestamp

Необов'язковий параметр timestamp — це позначка часу Unix типу int, яка стандартно дорівнює поточному місцевому часу, якщо timestamp не вказаний або null. Тобто є результатом функції time().

associative

Determines whether the function should return a regular, numerically indexed array, or an associative one.

Значення, що повертаються

If associative is set to false or not supplied then the array is returned as a regular, numerically indexed array. If associative is set to true then localtime() returns an associative array containing the elements of the structure returned by the C function call to localtime. The keys of the associative array are as follows:

Помилки/виключення

Якщо часовий пояс хибний, то під час кожного виклику функції дати/часу виникатиме E_WARNING. Див. date_default_timezone_set().

Журнал змін

Версія Опис
8.0.0 timestamp is nullable now.

Приклади

Приклад #1 localtime() example

<?php
$localtime
= localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);
?>

Поданий вище приклад виведе щось схоже на:

Array
(
    [0] => 24
    [1] => 3
    [2] => 19
    [3] => 3
    [4] => 3
    [5] => 105
    [6] => 0
    [7] => 92
    [8] => 1
)

Array
(
    [tm_sec] => 24
    [tm_min] => 3
    [tm_hour] => 19
    [tm_mday] => 3
    [tm_mon] => 3
    [tm_year] => 105
    [tm_wday] => 0
    [tm_yday] => 92
    [tm_isdst] => 1
)

Прогляньте також