(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL intl >= 3.0.0)
IntlDateFormatter::getCalendarObject -- datefmt_get_calendar_object — 取得格式器日曆物件的副本
物件導向風格
程序式風格
取得這個格式化器內部使用的日曆物件副本。此日曆的類型(如公曆、日式、佛曆、民國、波斯曆、伊斯蘭曆等)和時區將與格式化器使用的類型和時區相符。物件的日期/時間未指定。
此函式沒有參數。
範例 #1 IntlDateFormatter::getCalendarObject() 範例
<?php
$formatter = IntlDateFormatter::create(
"fr_FR@calendar=islamic",
NULL,
NULL,
"GMT-01:00",
IntlDateFormatter::TRADITIONAL
);
$cal = $formatter->getCalendarObject();
var_dump(
$cal->getType(),
$cal->getTimeZone(),
$cal->getLocale(Locale::VALID_LOCALE)
);
以上範例將輸出:
string(7) "islamic" object(IntlTimeZone)#3 (4) { ["valid"]=> bool(true) ["id"]=> string(9) "GMT-01:00" ["rawOffset"]=> int(-3600000) ["currentOffset"]=> int(-3600000) } string(5) "fr_FR"