(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
日期格式器是一個具體類別,可以使用模式字串和/或預設模式,進行地區相關的日期格式化/解析。
此類別代表 ICU 日期格式化功能。它允許使用者以當地語系化的格式顯示日期,或使用模式字串和/或預設模式將字串解析為 PHP 日期值。
$locale,$dateType = IntlDateFormatter::FULL,$timeType = IntlDateFormatter::FULL,$timezone = null,$calendar = null,$pattern = null$locale,$dateType = IntlDateFormatter::FULL,$timeType = IntlDateFormatter::FULL,$timezone = null,$calendar = null,$pattern = null$datetime, 陣列|整數|字串|null $format = null, ?字串 $locale = null): 字串|false這些常數用於在 DateType 和 TimeType 的建構子中指定不同的格式。
IntlDateFormatter::NONE 整數 (int)IntlDateFormatter::FULL 整數 (int)IntlDateFormatter::LONG 整數 (int)IntlDateFormatter::MEDIUM 整數 (int)IntlDateFormatter::SHORT 整數 (int)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"。
| 版本 | 說明 |
|---|---|
| 8.4.0 | 類別常數現在已設定類型。 |