getdate

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

getdate — Get date/time information


설명

getdate(?int $timestamp = null): array

timestamp의 날짜 정보를 포함하는 연관 배열을 반환하거나 timestamp가 생략되거나 null인 경우 현재 현지 시간을 반환합니다.


매개변수

timestamp
선택적 timestamp 매개변수는 timestamp가 생략되거나 null인 경우 현재 현지 시간으로 기본 설정되는 int Unix 타임스탬프입니다. 즉, 기본값은 time() 값입니다.

반환 값

timestamp와 관련된 정보의 연관 배열을 반환합니다. 반환된 연관 배열의 요소는 다음과 같습니다.

반환된 연관 배열의 키 요소

Key 설명 Example returned values
"seconds" Numeric representation of seconds 0 to 59
"minutes" Numeric representation of minutes 0 to 59
"hours" Numeric representation of hours 0 to 23
"mday" Numeric representation of the day of the month 1 to 31
"wday" Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
"mon" Numeric representation of a month 1 through 12
"year" A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"yday" Numeric representation of the day of the year 0 through 365
"weekday" A full textual representation of the day of the week Sunday through Saturday
"month" A full textual representation of a month, such as January or March January through December
0 Seconds since the Unix Epoch, similar to the values returned by time() and used by date(). System Dependent, typically -2147483648 through 2147483647.

변경 로그

버전 설명
8.0.0 timestamp는 이제 nullable입니다.

Examples

예제 #1 getdate() 예제

                  
<?php
$today = getdate();
print_r($today);
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

Array
(
    [seconds] => 40
    [minutes] => 58
    [hours]   => 21
    [mday]    => 17
    [wday]    => 2
    [mon]     => 6
    [year]    => 2003
    [yday]    => 167
    [weekday] => Tuesday
    [month]   => June
    [0]       => 1055901520
)
                

기타

  • date() - 현지 시간/날짜 형식 지정
  • idate() - 현지 시간/날짜를 정수로 포맷
  • localtime() - 현지 시간 가져오기
  • time() - 현재 Unix 타임스탬프 반환
  • setlocale() - 로케일 정보 설정