gpt4 book ai didi

php - IntlDateFormatter 返回错误的年份

转载 作者:行者123 更新时间:2023-12-04 02:41:36 25 4
gpt4 key购买 nike

如果你运行下面的代码

<?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 是我们习惯的常规年份引用。所以要获得当前年份替换 YYYYyyyy它应该完成这项工作

关于php - IntlDateFormatter 返回错误的年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59115111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com