php timezone returns empty array

痴心易碎 提交于 2019-12-25 11:55:32

问题


i have a server and a local development machine. On my locale machine, if I want to create a new DateTimezone with UTC, it's ok, the response:

php -r '$a = new \DateTimeZone("UTC"); var_dump($a);'
class DateTimeZone#1 (2) {
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(3) "UTC"
}

But on the other and on the server, if I type in this same command I get back this:

php -r '$a = new \DateTimeZone("UTC"); var_dump($a);'
object(DateTimeZone)#1 (0) {
}

In both cases date.timezone set to Europe/Berlin in apache2 and also in the cli config file.

Any idea?


回答1:


Ok, I found the problem since. The server had php 5.4 the local php 5.5, in 5.5 there is a __toString() method, in 5.4 it's not there yet.



来源:https://stackoverflow.com/questions/26904376/php-timezone-returns-empty-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!