(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, array|int|string|null $format = null, ?string $locale = null): string|false这些常量用于在 DateType 和 TimeType 的构造函数中指定不同的格式。
IntlDateFormatter::NONE intIntlDateFormatter::FULL intIntlDateFormatter::LONG intIntlDateFormatter::MEDIUM intIntlDateFormatter::SHORT intIntlDateFormatter::RELATIVE_FULL intIntlDateFormatter::FULL相同,但昨天、今天和明天分别显示为yesterday、today和tomorrow。从 PHP 8.0.0 开始可用,仅限于dateType。
IntlDateFormatter::RELATIVE_LONG intIntlDateFormatter::LONG相同,但昨天、今天和明天分别显示为yesterday、today和tomorrow。从 PHP 8.0.0 开始可用,仅限于dateType。
IntlDateFormatter::RELATIVE_MEDIUM intIntlDateFormatter::MEDIUM相同,但昨天、今天和明天分别显示为yesterday、today和tomorrow。从 PHP 8.0.0 开始可用,仅限于dateType。
IntlDateFormatter::RELATIVE_SHORT intIntlDateFormatter::SHORT相同,但昨天、今天和明天分别显示为yesterday、today和tomorrow。从 PHP 8.0.0 开始可用,仅限于dateType。
以下 int 常量用于指定日历。这些日历都直接基于公历。非公历需要在语言环境中指定。例如:locale="hi@calendar=BUDDHIST"。
| 版本 | 描述 |
|---|---|
| 8.4.0 | 类常量现在已添加类型。 |