天天看點

PHP date()函數警告: It is not safe to rely on the system解決方法

通路網站提示:

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 ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead

大體是說timezone沒有設定,在中國使用的是格林+8小時,是以需要設定一下。

解決方法1:修改php.ini

                  添加:date.timezone = "Asia/Shanghai"

解決方法2:在php.ini裡找到date.timezone這行,把值改成PRC,如date.timezone = PRC。

                   如果沒有這一行直接加上就好。最後重新開機WEB伺服器與PHP即可。

注:有時候方法1不能湊效,用方法2就立即生效。

本文轉自 boy461205160 51CTO部落格,原文連結:http://blog.51cto.com/461205160/1740757