IntlDateFormatter 不返回特定的非位置时区格式 (z)

问题描述 投票:0回答:1

我的应用程序突然开始显示错误的时区格式。 我总是将“12/11/2018 3:55 AM AEST”作为输出 但现在它返回“12/11/2018 3:55 AM GMT+11”。 代码:

$formatter = new IntlDateFormatter('en-US', IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'Australia/Sydney', null, "dd/MM/yyyy h:mm a z");
echo $formatter->format(new DateTime());

有没有简单的方法可以解决这个问题?

我使用带有 intl 扩展的 php7.0 和 ICU 版本 60.2 Ubuntu 18.04

php timezone icu intl
1个回答
0
投票

将国家代码更改为澳大利亚 (

en_AU
)。

使用美国国家代码 (

en_US
),美国人不太可能知道 AEST 的含义,或者可能会将其与美国东部标准时间混淆。在某些时候,ICU 开发人员可能决定显示其他国家/地区的时区作为补偿,以防止混淆。

$formatter = new IntlDateFormatter(
    'en_AU',
    IntlDateFormatter::NONE,
    IntlDateFormatter::NONE,
    'Australia/Sydney',
    null,
    "dd/MM/yyyy h:mm a z"
);
echo $formatter->format(new DateTime());
// 12/11/2018 3:55 AM AEST
© www.soinside.com 2019 - 2024. All rights reserved.