運作PHP應用,出現如下錯誤資訊:
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.
這是因為PHP所取的時間是格林威治标準時間,是以和你當地的時間會有出入格林威治标準時間和中原標準時間大概差8個小時左右。
我們可以按照下面的方法解決:
1、 在頁頭使用date_default_timezone_set()設定我的預設時區為中原標準時間,即<?phpdate_default_timezone_set("PRC");?>就可以了。
2、 在php.ini中設定date.timezone的值為PRC,設定好以後的為:date.timezone=PRC,同時取消這一行代碼的注釋,即去掉前面的分号就可以了。
本文轉自 tywali 51CTO部落格,原文連結:http://blog.51cto.com/lancelot/1772959,如需轉載請自行聯系原作者