如果你运行下面的代码
<?php
$date = new DateTime('2019-12-30 19:45:00', new DateTimeZone('Europe/London'));
$formatter = new IntlDateFormatter(
'en_GB',
null,
null,
'Europe/London',
IntlDateFormatter::GREGORIAN,
'MMMM YYYY'
);
echo $formatter->format($date);
它会 echo
December 2020
.这是类(class)的错误,还是我做错了什么,因为我希望它返回 December 2019
最佳答案
根据:
http://userguide.icu-project.org/formatparse/datetime
Y 代表“一年中的一周”(无论它意味着什么),而 y 是我们习惯的常规年份引用。所以要获得当前年份替换 YYYY
与 yyyy
它应该完成这项工作
关于php - IntlDateFormatter 返回错误的年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59115111/