PHP.nl

localtime

localtime

Get the local time

array **localtime**  $timestamp bool $associative

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

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

If is set to false or not supplied then the array is returned as a regular, numerically indexed array. If is set to true then 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: associative``associative``localtime

  • "tm_sec" - seconds, to 0``59

  • "tm_min" - minutes, to 0``59

  • "tm_hour" - hours, to 0``23

  • "tm_mday" - day of the month, to 1``31

  • "tm_mon" - month of the year, (Jan) to (Dec) 0``11

  • "tm_year" - years since 1900

  • "tm_wday" - day of the week, (Sun) to (Sat) 0``6

  • "tm_yday" - day of the year, to 0``365

  • "tm_isdst" - is daylight savings time in effect? Positive if yes, if not, negative if unknown. 0

    Voorbeeld: 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
)

getdate