PHP错误提示It is not safe to rely on the system……的解决方法

发布时间:2022-04-16 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP错误提示It is not safe to rely on the system……的解决方法脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

在Php程序开发中有时会出现类似于这样的警告:

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 getting this warning, you most likely missPElled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in......

能这这警告的提示信息我们可以初步知道是时区问题,这是因为PHP默认获取的时间是格林威治标准时间,所以这个时间会和标准北京时间相差8个小时,对于这个错误我们可以选用下面两个方法之中的一个就可以解决。

1、在页头使用date_default_timezone_set('PRC')设置时区为北京时间即可。

2、在服务器PHP配置文件 php.ini 中设置date.timezone的值为PRC;找到date.timezone=PRC,同时去掉前面的分号,即取消这一行代码的注释,如果没有此句可自行加上,然后重启web服务器即可。

关于PHP时间方面的知识可参考:PHP时间函数使用详解

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本宝典的支持。如果你想了解更多相关内容请查看下面相关链接

脚本宝典总结

以上是脚本宝典为你收集整理的PHP错误提示It is not safe to rely on the system……的解决方法全部内容,希望文章能够帮你解决PHP错误提示It is not safe to rely on the system……的解决方法所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:php报错