当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP错误提示It is not safe to rely on the system……的解决方法

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

2019年07月19日  | 移动技术网IT编程  | 我要评论

在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时间函数使用详解

总结

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网