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? 現(xiàn)象
運(yùn)行PHP應(yīng)用,出現(xiàn)如下錯(cuò)誤信息:
| 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? 原因
這是因?yàn)镻HP所取的時(shí)間是格林威治標(biāo)準(zhǔn)時(shí)間,所以和你當(dāng)?shù)氐臅r(shí)間會(huì)有出入格林威治標(biāo)準(zhǔn)時(shí)間和北京時(shí)間大概差8個(gè)小時(shí)左右。
1.1.3? 解決
我們可以按照下面的方法解決:
1、 在頁頭使用date_default_timezone_set()設(shè)置我的默認(rèn)時(shí)區(qū)為北京時(shí)間,即<?phpdate_default_timezone_set("PRC");?>就可以了。
2、 在php.ini中設(shè)置date.timezone的值為PRC,設(shè)置好以后的為:date.timezone=PRC,同時(shí)取消這一行代碼的注釋,即去掉前面的分號(hào)就可以了。
本文轉(zhuǎn)自 tywali 51CTO博客,原文鏈接:http://blog.51cto.com/lancelot/1772959,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的PHP问题 —— It is not safe to rely on the system's的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python面向对象基础
- 下一篇: php网页跳转无法获取session值