php date 有warning,php提示PHP Warning: date(): It is not safe to rely on the......错误的解决办法...
在寫php程序中有時會出現(xiàn)這樣的警告:
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')設(shè)置時區(qū)為北京時間即可。
2、在服務(wù)器配置文件 php.ini 中設(shè)置date.timezone的值為PRC,設(shè)置好以后的為:date.timezone=PRC,同時去掉前面的分號,即取消這一行代碼的注釋。
提示:date_timezone_set — 別名 DateTime::setTimezone()
總結(jié)
以上是生活随笔為你收集整理的php date 有warning,php提示PHP Warning: date(): It is not safe to rely on the......错误的解决办法...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从佛山南海怎样坐地铁到广洲金沙洲?
- 下一篇: java前期_【JAVA】前期环境配置