小編給大家分享一下PHP中date()函數警告: It is not safe to rely on the system怎么辦,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
近來總是有系統郵件提示,開始沒在意,后來不斷提示就看了一下。提示以下信息
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 gett
ing this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /data0/htdocs/www.qttc.net/function/function.php on line 542
大體是說timezone沒有設置,在中國使用的是格林+8小時,所以需要設置一下。
第一種
在頁面頭部加入以下語句
date_default_timezone_set("PRC");
這種方法有個缺點,就是所有的頁面都得添加
第二種
在php.ini里找到date.timezone這行,把值改成PRC,如date.timezone = PRC。如果沒有這一行直接加上就好。最后重啟WEB服務器與PHP即可。
看完了這篇文章,相信你對“PHP中date()函數警告: It is not safe to rely on the system怎么辦”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。