php日期返回无效小时

lsmepo6l  于 12个月前  发布在  PHP
关注(0)|答案(2)|浏览(58)

此代码date("H:i")返回无效的小时:分钟。
当前时间windows server 2016是10:55但是date("H:i")返回11:55!?
我的PHP版本是5.6.37,安装了timezonedb扩展,但我仍然有这个问题。
我将时区设置为Asia/Tehran,并使用date_default_timezone_get()获取当前值,一切正常。

结果PHP代码:

4si2a6ki

4si2a6ki1#

我在这里找到了新闻https://www.timeanddate.com/news/time/iran-dst-2022.html,它说伊朗已经决定从2023年取消夏令时,所以请确保您已经安装了lastest timezonedb extension。你可以用下面的代码来检查它:

date_default_timezone_set('Asia/Tehran');
echo date('I'); # should be 0
ogsagwnx

ogsagwnx2#

伊朗现在有夏令时,所以我建议你更新你的操作系统,或者使用外部第三方服务来获取当前时间。
获取更多信息Official Time Zone Authority

相关问题