温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP中date()函数警告: It is not safe to rely on the system怎么办

发布时间:2021-09-29 14:43:00 来源:亿速云 阅读:85 作者:小新 栏目:开发技术

小编给大家分享一下PHP中date()函数警告: It is not safe to rely on the system怎么办,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

近来总是有系统邮件提示,开始没在意,后来不断提示就看了一下。提示以下信息

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 gett
ing this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /data0/htdocs/www.qttc.net/function/function.php on line 542


大体是说timezone没有设置,在中国使用的是格林+8小时,所以需要设置一下。

第一种

在页面头部加入以下语句

date_default_timezone_set("PRC");


这种方法有个缺点,就是所有的页面都得添加

第二种

在php.ini里找到date.timezone这行,把值改成PRC,如date.timezone = PRC。如果没有这一行直接加上就好。最后重启WEB服务器与PHP即可。

看完了这篇文章,相信你对“PHP中date()函数警告: It is not safe to rely on the system怎么办”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI