(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)
はじめに
Date Formatter は、パターン文字列や出来合いのパターンを使用して ロケールに依存する日付のフォーマット/パースを行う具象クラスです。
このクラスは ICU の日付フォーマット機能を表します。 これを使用すると、パターン文字列や出来合いのパターンを使用して 日付を各地域のフォーマットで表示したり、 文字列をパースして PHP の日付として扱ったりすることができます。
クラス概要
IntlDateFormatter {
public
__construct
( string $locale
, int $datetype
, int $timetype
[, mixed $timezone
= NULL
[, mixed $calendar
= NULL
[, string $pattern
= ""
]]] )
public
static
create
( string $locale
, int $datetype
, int $timetype
[, mixed $timezone
= NULL
[, mixed $calendar
= NULL
[, string $pattern
= ""
]]] ) : IntlDateFormatter
public static formatObject
( object $object
[, mixed $format
= NULL
[, string $locale
= NULL
]] ) : string|false
public getCalendar ( ) : int
public getDateType ( ) : int
public getErrorCode ( ) : int
public getErrorMessage ( ) : string
public getLocale
([ int $which
] ) : string
public getPattern ( ) : string
public getTimeType ( ) : int
public getTimeZoneId ( ) : string
public getCalendarObject ( ) : IntlCalendar
public getTimeZone ( ) : IntlTimeZone|false
public isLenient ( ) : bool
public localtime
( string $value
[, int &$position
] ) : array
public parse
( string $value
[, int &$position
] ) : int
public setCalendar
( mixed $which
) : bool
public setLenient
( bool $lenient
) : bool
public setPattern
( string $pattern
) : bool
public setTimeZoneId
( string $zone
) : bool
public
setTimeZone
( mixed $zone
) : bool
}
定義済み定数
これらの定数は、DateType や TimeType のコンストラクタでさまざまなフォーマットを指定するために使用します。
IntlDateFormatter::NONE
(int)- この要素を含まない
IntlDateFormatter::FULL
(int)- 完全に指定した形式 (Tuesday, April 12, 1952 AD あるいは 3:30:42pm PST)
IntlDateFormatter::LONG
(int)- 長い形式 (January 12, 1952 あるいは 3:30:32pm)
IntlDateFormatter::MEDIUM
(int)- 中間の形式 (Jan 12, 1952)
IntlDateFormatter::SHORT
(int)- 不可欠なデータのみを扱う最も省略した形式 (12/13/52 あるいは 3:30pm)
IntlDateFormatter::RELATIVE_FULL
(int)-
IntlDateFormatter::FULL
と同じですが、 昨日、今日、明日についてはそれぞれ、yesterday
,today
,tomorrow
になります。 PHP 8.0.0 以降で、dateType
に限って利用可能です。 IntlDateFormatter::RELATIVE_LONG
(int)-
IntlDateFormatter::LONG
と同じですが、 昨日、今日、明日についてはそれぞれ、yesterday
,today
,tomorrow
になります。 PHP 8.0.0 以降で、dateType
に限って利用可能です。 IntlDateFormatter::RELATIVE_MEDIUM
(int)-
IntlDateFormatter::MEDIUM
と同じですが、 昨日、今日、明日についてはそれぞれ、yesterday
,today
,tomorrow
になります。 PHP 8.0.0 以降で、dateType
に限って利用可能です。 IntlDateFormatter::RELATIVE_SHORT
(int)-
IntlDateFormatter::SHORT
と同じですが、 昨日、今日、明日についてはそれぞれ、yesterday
,today
,tomorrow
になります。 PHP 8.0.0 以降で、dateType
に限って利用可能です。
次の整数定数は、暦の種類を指定するものです。 これらの暦は、すべてグレゴリオ暦にもとづくものです。 グレゴリオ暦以外の暦はロケールで指定しなければなりません。 たとえば、 locale="hi@calendar=BUDDHIST" のようになります。
IntlDateFormatter::TRADITIONAL
(int)- 非グレゴリオ暦
IntlDateFormatter::GREGORIAN
(int)- グレゴリオ暦
目次
- IntlDateFormatter::create — Date Formatter を作成する
- IntlDateFormatter::format — 日付/時刻 の値を文字列としてフォーマットする
- IntlDateFormatter::formatObject — オブジェクトの書式を設定する
- IntlDateFormatter::getCalendar — IntlDateFormatter が使用するカレンダー型を取得する
- IntlDateFormatter::getDateType — IntlDateFormatter が使用する日付形式を取得する
- IntlDateFormatter::getErrorCode — 直近の操作のエラーコードを取得する
- IntlDateFormatter::getErrorMessage — 直近の操作のエラーテキストを取得する
- IntlDateFormatter::getLocale — Formatter が使用するロケールを取得する
- IntlDateFormatter::getPattern — IntlDateFormatter が使用するパターンを取得する
- IntlDateFormatter::getTimeType — IntlDateFormatter が使用する時刻形式を取得する
- IntlDateFormatter::getTimeZoneId — IntlDateFormatter が使用するタイムゾーン ID を取得する
- IntlDateFormatter::getCalendarObject — カレンダーオブジェクトのコピーを取得する
- IntlDateFormatter::getTimeZone — タイムゾーンを取得する
- IntlDateFormatter::isLenient — IntlDateFormatter で使用する寛大さを取得する
- IntlDateFormatter::localtime — 文字列をパースして、フィールドベースの時刻値にする
- IntlDateFormatter::parse — 文字列をパースしてタイムスタンプにする
- IntlDateFormatter::setCalendar — Formatter が使うカレンダー型を設定する
- IntlDateFormatter::setLenient — パーサの寛大さを設定する
- IntlDateFormatter::setPattern — IntlDateFormatter が使用するパターンを設定する
- IntlDateFormatter::setTimeZoneId — 使用するタイムゾーンを設定する
- IntlDateFormatter::setTimeZone — タイムゾーンを設定する
/* メソッド */