PHP Conference Japan 2024

IntlDateFormatter::getCalendarObject

datefmt_get_calendar_object

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL intl >= 3.0.0)

IntlDateFormatter::getCalendarObject -- datefmt_get_calendar_object取得格式器日曆物件的副本

說明

物件導向風格

public IntlDateFormatter::getCalendarObject(): IntlCalendar|false|null

程序式風格

datefmt_get_calendar_object(IntlDateFormatter $formatter): IntlCalendar|false|null

取得這個格式化器內部使用的日曆物件副本。此日曆的類型(如公曆、日式、佛曆、民國、波斯曆、伊斯蘭曆等)和時區將與格式化器使用的類型和時區相符。物件的日期/時間未指定。

參數

此函式沒有參數。

回傳值

此格式化器使用的內部日曆物件的副本,如果未設定則為 null,失敗則為 false

範例

範例 #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"

參見

新增註釋

使用者提供的註釋

此頁面沒有使用者提供的註釋。
To Top