Internationalization IntlDateFormatter::setCalendar
IntlDateFormatter::setCalendar
datefmt_set_calendar
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
IntlDateFormatter::setCalendar -- datefmt_set_calendar — 포맷터에서 사용하는 달력 유형을 설정합니다.
설명
객체 지향 스타일
public IntlDateFormatter::setCalendar(IntlCalendar|int|null $calendar
): bool
절차 스타일:
datefmt_set_calendar(IntlDateFormatter $formatter
, IntlCalendar|int|null $calendar
): bool
포맷터에서 사용하는 달력 또는 달력 유형을 설정합니다.
매개변수
formatter
- 포맷터 리소스.
calendar
- 사용할 달력 유형(기본값은
IntlDateFormatter::GREGORIAN
이며null
이 지정된 경우에도 사용됨) 또는 IntlCalendar 개체일 수 있습니다.전달된 모든 IntlCalendar 개체가 복제됩니다. 인수 개체는 수정되지 않습니다.
포맷터의 표준 시간대는 IntlCalendar 개체가 전달되지 않은 경우에만 유지되며, 그렇지 않으면 새 표준 시간대는 전달된 개체의 표준 시간대가 됩니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
5.5.0/PECL 3.0.0 | IntlCalendar 개체를 전달할 수 있게 되었습니다. |
Examples
예제 #1 datefmt_set_calendar() 예제
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . datefmt_get_calendar($fmt);
datefmt_set_calendar($fmt, IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . datefmt_get_calendar($fmt);
?>
예제 #2 OO 예제
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
echo 'calendar of the formatter is : ' . $fmt->getCalendar();
$fmt->setCalendar(IntlDateFormatter::TRADITIONAL);
echo 'Now calendar of the formatter is : ' . $fmt->getCalendar();
?>
위의 예는 다음을 출력합니다.
calendar of the formatter is : 1 Now calendar of the formatter is : 0
예제 #3 IntlCalendar 인수가 있는 예
<?php
$time = strtotime("2013-03-03 00:00:00 UTC");
$formatter = IntlDateFormatter::create("en_US", NULL, NULL, "Europe/Amsterdam");
echo "before: ", $formatter->format($time), "\n";
/* note that the calendar's locale is not used! */
$formatter->setCalendar(IntlCalendar::createInstance(
"America/New_York", "pt_PT@calendar=islamic"));
echo "after: ", $formatter->format($time), "\n";
위의 예는 다음을 출력합니다.
before: Sunday, March 3, 2013 at 1:00:00 AM Central European Standard Time after: Saturday, Rabiʻ II 20, 1434 at 7:00:00 PM Eastern Standard Time
기타
- datefmt_get_calendar() - IntlDateFormatter에 사용되는 달력 유형을 가져옵니다.
- datefmt_get_calendar_object() - 포맷터의 캘린더 개체 사본 가져오기
- datefmt_create() - 날짜 포맷터 만들기