PHP 日期问题 PHP Warning: date(): It is not safe to rely on the system’s timezone settings
2013-05-09 14:02
411 查看
PHP Warning: date(): It is not safe to rely on the system’s timezone settings
通过观察nginx的错误日志,发现大量的如下错误:
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting
this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in
通过搜索,发现从php5.3 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。知道了问题的根源,解决的方法有三种,任选一种即可。
一、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC');
二、在页头使用ini_set('date.timezone','Asia/Shanghai');
三、修改php.ini。打开php5.ini查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC
注意:上述设置都是针对中国大陆来设置的,同时PRC也可以用Asia/Shanghai,Asia/Chongqing,Asia/Urumqi来代替。
通过观察nginx的错误日志,发现大量的如下错误:
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting
this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in
通过搜索,发现从php5.3 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。知道了问题的根源,解决的方法有三种,任选一种即可。
一、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC');
二、在页头使用ini_set('date.timezone','Asia/Shanghai');
三、修改php.ini。打开php5.ini查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC
注意:上述设置都是针对中国大陆来设置的,同时PRC也可以用Asia/Shanghai,Asia/Chongqing,Asia/Urumqi来代替。
相关文章推荐
- PHP Warning: date(): It is not safe to rely on the system's timezone settings.
- php Warning: date(): It is not safe to rely on the system's timezone settings.
- php Warning:date(): It is not safe to rely on the system's timezone settings
- PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings.
- 关于php中Warning: date(): It is not safe to rely on the system's timezone settings.解决
- "PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You
- PHP Warning: date(): It is not safe to rely on the system’s timezone settings
- PHP Warning: date(): It is not safe to rely on the system’s timezone settings
- php首次使用date函数 遇到警告:Warning:date():It is not safe to rely on the system's timezone settings.You...
- PHP Warning: date(): It is not safe to rely on the system’s timezone settings
- 解决php的It is not safe to rely on the system’s timezone settings的问题
- PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings.处理方法
- 解决php的It is not safe to rely on the system’s timezone settings的问题
- Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system's timezone settings.
- Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.
- 解决php的“It is not safe to rely on the system’s timezone settings”问题
- 解决php的It is not safe to rely on the system’s timezone settings的问题
- 解决php的It is not safe to rely on the system’s timezone settings的问题
- home 解决php的“It is not safe to rely on the system’s timezone settings”问题
- 解决php的It is not safe to rely on the system’s timezone settings的问题