php提前一小时显示 [英] php shows one hour early

查看:101
本文介绍了php提前一小时显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php.ini中的php设置:

date.timezone = Asia/Jerusalem.

我的Linux服务器(Ubuntu)显示正确的时间: Wed Oct 1 15:35:39 IDT 2014

但是当我echo date('Y-m-d H:i:s');时,我得到了2014-10-01 14:35:39(一个小时前).

我也尝试过date_default_timezone_set('Asia/Jerusalem');,但结果相同

为什么结果不正确?

解决方案

在过去的几年中,以色列对夏令时进行了几处更改. DST应该在今年10月26日生效. DST结束日期最后一次落在10月1日之前的时间是2012年9月23日.参考.

以色列宣布2013年以后的更改时,它们已在标准 IANA时区数据库中发布在2013d版本中.当时,我实际上回答了类似的问题,关于Java如何处理此更改.

对于PHP,IANA数据库是通过 timezonedb PECL软件包实现的.您可以手动安装此软件包以更新到最新版本的时区数据.

PHP内部还附带了一个timezonedb副本,该副本应该是发布PHP版本时可用的最新版本.因此,只需将PHP升级到最新版本也可以解决问题.

如果要查看当前具有的时区数据库版本(是内置的还是已更新的)-您可以调用timezone_version_get() 解决方案

Israel has undergone several changes to daylight saving time in the last few years. This year, DST is supposed to be in effect until October 26th. The last time the DST end date fell before October 1st was September 23, 2012. Reference here.

When Israel announced the changes for 2013 forward, they were released in the standard IANA time zone database in version 2013d. I actually answered a similar question back then, regarding how Java handles this change.

For PHP, the IANA database is implemented via the timezonedb PECL package. You can install this package manually to update to the latest version of the timezone data.

PHP also comes with a copy of timezonedb internally, which is supposed to be the most recent version available at the time that the PHP version is released. So simply upgrading PHP to the latest version should also solve the problem.

If you want to see what version of timezonedb you currently have (whether built-in, or updated) - you can call timezone_version_get(), as documented here. It needs to be at least 2013.4 to have this particular change. The current release is 2014.7.

这篇关于php提前一小时显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆