IntlDateFormatter::getCalendarObject

datefmt_get_calendar_object

カレンダーオブジェクトのコピーを取得する

説明

オブジェクト指向型

public IntlCalendarfalsenull IntlDateFormatter::getCalendarObject()

手続き型

IntlCalendarfalsenull datefmt_get_calendar_object(IntlDateFormatter $formatter)

このフォーマッターが内部的に使うカレンダーオブジェクトのコピーを取得します。 このカレンダーには型 (gregorian、japanese、buddhist、roc、persian、 islamic など) やタイムゾーンが設定されており、フォーマッターが使っている型やタイムゾーンと一致します。 オブジェクトの日付や時刻は指定されていません。

パラメータ

この関数にはパラメータはありません。

戻り値

このフォーマッターが内部的に使うカレンダーオブジェクトのコピーを返します。 何も設定されなかった場合は 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"

参考

  • IntlDateFormatter::getCalendar
  • IntlDateFormatter::setCalendar
  • IntlCalendar