localtime
(PHP 4, PHP 5)
localtime — Get the local time
설명
The localtime() function returns an array identical to that of the structure returned by the C function call.
매개변수
- timestamp
-
선택적인 timestamp 매개변수는 현재 로컬 시간을 기본값으로 가지는 integer 유닉스 타임스탬프입니다. 즉, 기본값은 time() 값입니다.
- is_associative
-
If set to FALSE or not supplied than the array is returned as a regular, numerically indexed array. If the argument is set to TRUE then localtime() is an associative array containing all the different elements of the structure returned by the C function call to localtime. The names of the different keys of the associative array are as follows:
- "tm_sec" - seconds
- "tm_min" - minutes
- "tm_hour" - hour
- "tm_mday" - day of the month Months are from 0 (Jan) to 11 (Dec) and days of the week are from 0 (Sun) to 6 (Sat).
- "tm_mon" - month of the year, starting with 0 for January
- "tm_year" - Years since 1900
- "tm_wday" - Day of the week
- "tm_yday" - Day of the year
- "tm_isdst" - Is daylight savings time in effect
오류/예외
모든 날짜/시간 함수 호출은 시간대가 유효하지 않을 때 E_NOTICE를, 시스템 설정이나 TZ 환경 변수를 사용할 때 E_STRICT를 생성합니다. date_default_timezone_set()을 참고하십시오.
변경 기록
버전 | 설명 |
---|---|
5.1.0 | Now issues the E_STRICT and E_NOTICE time zone errors. |
예제
Example#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 )