Php/docs/class.intldateformatter

提供:Dev Guides
< Php
移動先:案内検索

(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 format ( mixed $value ) : string

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 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)
グレゴリオ暦


目次