php日期提示警告,php程序报date()警告的处理的解决方法
本篇講解php程序報date()警告的處理的解決方法。
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
在寫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 D:\PHPWEB ews\file.php on line 17 。
這是因為PHP所取的時間是格林威治標準時間,所以和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右,我們可以按照下面的方法解決:
1、在頁頭使用date_default_timezone_set()設置我的默認時區為北京時間,即
就可以了。
2、在php.ini中設置date.timezone的值為PRC,設置好以后的為:date.timezone=PRC或者date.timezone = Asia/Shanghai,同時取消這一行代碼的注釋,即去掉前面的分號就可以了。
然后重啟apache即可!
本篇講解php程序報date()警告的處理的解決方法,更多相關內容請關注php中文網。
相關推薦:
總結
以上是生活随笔為你收集整理的php日期提示警告,php程序报date()警告的处理的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab单边衰减正弦信号,指数衰减正
- 下一篇: php阻止form提交表单提交,防止表单