It is not safe to rely on the system's timezone

简介:

It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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....


网站在windows服务器上正常。但是网站搬到Linux服务器上就报这个错(php版本为5.3)。为什么会默认重庆呢?j_0016.gif


162953737.png


解决办法:

网上很多说修改下php.ini中的date.timezone =PRC即可。(但是我修改、重启后还是报错)


实际上,从 PHP 5.1.0 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是PHP5.3中好像如果没有设置也会强行抛出了这个错误的,解决此问题,只要本地化一下,就行了。


故只能在本地用到了Date()函数的各代码顶部加上(这多麻烦啊):

date_default_timezone_set('PRC');        //东八时区

或:

date_default_timezone_set('Asia/Shanghai');

或:

ini_set('date.timezone','Asia/Shanghai');






      本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/1241593,如需转载请自行联系原作者




相关文章
|
5月前
|
Ubuntu Docker 容器
System has not been booted with systemd as init system (PID 1). Can‘t operate.
System has not been booted with systemd as init system (PID 1). Can‘t operate.
|
11月前
Server returns invalid timezone
Server returns invalid timezone
|
关系型数据库 MySQL
Mysql current_time,current_date()与now()区别
Mysql current_time,current_date()与now()区别
|
关系型数据库 MySQL Java
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
4177 1
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
|
SQL Oracle 关系型数据库