It is not safe to rely on the system's timezone

It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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....


網站在windows服務器上正常。但是網站搬到Linux服務器上就報這個錯(php版本爲5.3)。爲什麼會默認重慶呢?



解決辦法:

網上很多說修改下php.ini中的date.timezone =PRC即可。(但是我修改、重啓後還是報錯)


實際上,從 PHP 5.1.0 ,當對使用date()等函數時,如果timezone設置不正確,在每一次調用時間函數時,都會產生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone這個選項,默認情況下是關閉的,無論用什麼php命令都是格林威治標準時間,但是PHP5.3中好像如果沒有設置也會強行拋出了這個錯誤的,解決此問題,只要本地化一下,就行了。


故只能在本地用到了Date()函數的各代碼頂部加上(這多麻煩啊):

date_default_timezone_set('PRC');        //東八時區

或:

date_default_timezone_set('Asia/Shanghai');

或:

ini_set('date.timezone','Asia/Shanghai');



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章