PHP date()函数警告: It is not safe to rely on the system解决方法
近来总是有系统邮件提示,开始没在意,后来不断提示就看了一下。提示以下信息
PHPWarning: date():Itisnotsafetorelyonthesystem'stimezonesettings.Youare*required*tousethedate.timezonesettingorthedate_default_timezone_set()function.Incaseyouusedanyofthosemethodsandyouarestillgett ingthiswarning,youmostlikelymisspelledthetimezoneidentifier.Weselected'Asia/Chongqing'for'CST/8.0/noDST'insteadin/data0/htdocs/www.qttc.net/function/function.phponline542
大体是说timezone没有设置,在中国使用的是格林+8小时,所以需要设置一下。
第一种
在页面头部加入以下语句
date_default_timezone_set("PRC");
这种方法有个缺点,就是所有的页面都得添加
第二种
在php.ini里找到date.timezone这行,把值改成PRC,如date.timezone=PRC。如果没有这一行直接加上就好。最后重启WEB服务器与PHP即可。
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便