加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP date()函数警示 It is not safe to rely on the system解决方法

发布时间:2023-05-04 12:49:05 所属栏目:PHP教程 来源:
导读:这篇文章主要介绍了PHP date()函数警告: It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了两种方法来解决这个问题,需要的朋友可以参考下近来总是有系统邮件提示,开始没在意,

这篇文章主要介绍了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即可。

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!