idate
(PHP 5, PHP 7, PHP 8)
idate — 현지 시간/날짜를 정수로 형식화
설명
idate(string $format
, ?int $timestamp
= null
): int|false
지정된 정수 timestamp
를 사용하여 지정된 형식 문자열에 따라 형식이 지정된 문자열을 반환하거나 timestamp
가 지정되지 않은 경우 현재 시간을 반환합니다. 즉, timestamp
는 선택 사항이며 기본값은 time()입니다.
date() 함수와 달리 idate()는 format
매개변수에서 하나의 문자만 허용합니다.
매개변수
format
-
format
매개변수 문자열에서 다음 문자가 인식됩니다.format
character설명 B
Swatch Beat/Internet Time d
Day of the month h
Hour (12 hour format) H
Hour (24 hour format) i
Minutes I
(uppercase i)returns 1
if DST is activated,0
otherwiseL
(uppercase l)returns 1
for leap year,0
otherwisem
Month number s
Seconds t
Days in current month U
Seconds since the Unix Epoch - January 1 1970 00:00:00 UTC - this is the same as time() w
Day of the week ( 0
on Sunday)W
ISO-8601 week number of year, weeks starting on Monday y
Year (1 or 2 digits - check note below) Y
Year (4 digits) z
Day of the year Z
Timezone offset in seconds timestamp
- 선택적
timestamp
매개변수는timestamp
가 생략되거나null
인 경우 현재 현지 시간으로 기본 설정되는 int Unix 타임스탬프입니다. 즉, 기본값은 time() 값입니다.
반환 값
성공하면 int를 반환하고 실패하면 false
를 반환합니다.
idate()는 항상 int를 반환하고 "0"으로 시작할 수 없기 때문에 idate()는 예상보다 적은 숫자를 반환할 수 있습니다. 아래 예를 참조하십시오.
오류/예외
날짜/시간 함수에 대한 모든 호출은 시간대가 유효하지 않은 경우 E_WARNING
을 생성합니다. date_default_timezone_set()도 참조하십시오.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | timestamp 는 이제 nullable입니다. |
Examples
예제 #1 idate() 예제
<?php
$timestamp = strtotime('1st January 2004'); //1072915200
// this prints the year in a two digit format
// however, as this would start with a "0", it
// only prints "4"
echo idate('y', $timestamp);
?>