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,如需转载请自行联系原作者




相关文章
|
4月前
|
Java 数据库连接 数据库
The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than one time zone
The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than one time zone
28 0
|
Java 关系型数据库 MySQL
The server time zone value ‘?й???’ is unrecognized or represents more than one time zone. You must c
报错信息如下:The server time zone value ‘?й???’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
76 0
|
10月前
|
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.
216 0
|
关系型数据库 MySQL Java
超详解The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more than one time zone
超详解The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more than one time zone
463 0
|
数据库连接 数据库
The server time zone value ‘‘ is unrecognized or represents more than one time zone.
The server time zone value ‘‘ is unrecognized or represents more than one time zone.
|
关系型数据库 MySQL Java
The server time zone value '?й???????' is unrecognized or represents more than one time zone.
The server time zone value '?й???????' is unrecognized or represents more than one time zone.
80 0
The server time zone value '?й???????' is unrecognized or represents more than one time zone.
|
SQL 关系型数据库 MySQL
mysql 报错 is too long for user name (should be no longer than 16)
mysql 报错 is too long for user name (should be no longer than 16)
304 0
|
Java 数据库连接
JDBC - The server time zone value ‘???‘ is unrecognized or represents more than one time zone
JDBC - The server time zone value ‘???‘ is unrecognized or represents more than one time zone
93 0