PHP问题 —— It is not safe to rely on the system's
1.1? It is not safe to rely on the system's timezone settings
1.1.1? 現象
運行PHP應用,出現如下錯誤信息:
| 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. |
1.1.2? 原因
這是因為PHP所取的時間是格林威治標準時間,所以和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右。
1.1.3? 解決
我們可以按照下面的方法解決:
1、 在頁頭使用date_default_timezone_set()設置我的默認時區為北京時間,即<?phpdate_default_timezone_set("PRC");?>就可以了。
2、 在php.ini中設置date.timezone的值為PRC,設置好以后的為:date.timezone=PRC,同時取消這一行代碼的注釋,即去掉前面的分號就可以了。
本文轉自 tywali 51CTO博客,原文鏈接:http://blog.51cto.com/lancelot/1772959,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的PHP问题 —— It is not safe to rely on the system's的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python面向对象基础
- 下一篇: php网页跳转无法获取session值