php date()提前1小时服务器时间(DST问题) [英] php date() one hour ahead of server time (DST problem)

查看:226
本文介绍了php date()提前1小时服务器时间(DST问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决这个问题:
我正在处理的服务器(在Linux上为php 5.2.9),具有正确的本地时间(America / Buenos_Aires):

I'm trying to troubleshoot and solve this problem: the server I'm working on (php 5.2.9 on Linux), has the correct local time (America/Buenos_Aires):

user@server [/home/site/public_html]$ date
Mon Nov  1 17:11:14 ART 2010

php.ini 设置为 date.timezone =America / Buenos_Aires
我还尝试将脚本中的时区直接设置为

php.ini is set with date.timezone = "America/Buenos_Aires" I also tried to set the timezone directly in the script with

<?php
ini_set('display_errors', true);
error_reporting(E_ALL|E_STRICT|E_NOTICE);

//date_default_timezone_set("America/Buenos_Aires"); 
//echo  date_default_timezone_get(), "<br>";
echo "ini: ", ini_get('date.timezone'), "<br>";

$now = date("H:i:s T I");
$nowdate = date("Y-m-d");
echo $nowdate." ".$now;
?>

但无效,结果是

but to no avail, the result is

ini: America/Buenos_Aires
2010-11-01 18:11:14 ARST 1

当它应该读 17:11 (一直在一小时前)。我在网路上找到的所有内容都指向

when it should read 17:11 (It's consistently one hour ahead). All I've found here and on the web pointed to


  • date_default_timezone_set(我试过)

  • 在php.ini(设置)中设置date.timezone

  • 将服务器时间与客户端时间混淆(我不是)。

任何想法?

编辑:
如所建议的,正如您在代码中可以看到的,PHP认为应该应用DST,而阿根廷决定今年不适用。除了等待修补程序之外的任何选项?

As suggested, I checked and as you can see in the code, PHP thinks it should be applying DST, and Argentina decided to not apply it this year. Any option besides waiting for a patch?

编辑2:
我尝试根据建议转储时区转换。我得到以下内容:

EDIT 2: I tried dumping the timezones transition as suggested. I got the following:

The timezone America/Buenos_Aires switches to standard time on 20 Mar 2011 @ 02:00.
The new GMT offset will be: -10800 (ART) 


推荐答案

There was a question a few days back that suggested that PHP hasn't yet got wind of the fact that Argentina got rid of DST only this year. It seems like this decision hasn't made it into the code base yet. (But it was not confirmed, so it's not 100% clear whether this was it.)

也许尝试倾销您的时区,同样的方式来查看是否适用于您的PHP版本。

Maybe try dumping your time zones the same way to see whether that applies to your PHP version, too.

更新:这确实是个问题。我可以想到的最好的解决方案是在时区中使用偏移量,例如 Etc / GMT-3

Update: This indeed seems to be the problem. The best solution I can think of is to use an offset in the time zone, e.g. Etc/GMT-3

有人应该提交bugs.php.net的错误,似乎没有一个。

Somebody should file a bug with bugs.php.net, there doesn't seem to be one for this.

这篇关于php date()提前1小时服务器时间(DST问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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