您的位置:首页 > 编程学习 > > 正文

php执行超时怎么办(PHP错误提示It is not safe to rely on the system……的解决方法)

更多 时间:2022-04-03 11:23:56 类别:编程学习 浏览量:1115

php执行超时怎么办

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 报错 时区
您可能感兴趣