xlid 发表于 2017-4-10 11:15:45

php 5.3的升级引起的一些非兼容问题 之一

  安装了php 5.3之后,如果之前的代码遇到如下的问题:

Warning: date() : It is not safe to rely on the system'stimezone settings. You are *required* to use the date.timezone settingor the date_default_timezone_set() function. In case you used any ofthose methods and you are still getting this warning, you most likelymisspelled the timezone identifier. We selected 'Europe/Helsinki'

等等之类的,有如下解决办法:

1. 比较根本的,不需要修改自己代码的,需要设置php.ini中的:

date.timezone = "Europe/Berlin"

具体是设置服务器的默认时区,可以参考:
http://php.net/manual/en/timezones.php

2. 另一种方法,如果没有编辑php.ini的权限的话,可以在代码中添加:

date_default_timezone_set("Europe/Berlin");
页: [1]
查看完整版本: php 5.3的升级引起的一些非兼容问题 之一