【问题标题】:php wrong timezone issue in Australia/Sydney澳大利亚/悉尼的php错误时区问题
【发布时间】:2014-12-16 07:00:02
【问题描述】:

我想获取澳大利亚/悉尼的时区名称(不是时间)

http://php.net/manual/en/timezones.australia.php(时区设置)

$t = new DateTime('now'); 
$t->setTimeZone( new DateTimeZone('Australia/Sydney'));
echo $t->format("Y D M j H:i T");

结果 = 2014 年 12 月 16 日星期二 17:54 EST

http://www.timeanddate.com/time/zones/aedt

在此 URL 中,澳大利亚/悉尼是 AEDT。 为什么php返回EST?

【问题讨论】:

  • 您是否在本地尝试此代码?
  • 在我的服务器中。 php info : System Linux servername 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64

标签: php timezone


【解决方案1】:

希望这对你有用

$test = new DateTimeZone('Australia/Sydney');
$gmt = new DateTimeZone('AEDT');

$date = new DateTime('2011-12-25 00:00:00', $test);
$date->setTimezone($gmt);
echo $date->format('Y-m-d H:i:s');

【讨论】:

【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 2014-06-02
  • 1970-01-01
  • 2020-11-26
  • 1970-01-01
  • 2013-01-28
  • 2021-05-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多