運行PHP應用,出現以下錯誤信息: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.ide |
這是由於PHP所取的時間是格林威治標準時間,因此和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右。ui
咱們能夠按照下面的方法解決:this
一、 在頁頭使用date_default_timezone_set()設置個人默認時區爲北京時間,即<?phpdate_default_timezone_set("PRC");?>就能夠了。spa
二、 在php.ini中設置date.timezone的值爲PRC,設置好之後的爲:date.timezone=PRC,同時取消這一行代碼的註釋,即去掉前面的分號就能夠了。ci