When using PHP version above PHP5.3, as long as the time involved will be reported a
PHP warning:date () [function.date]: It is not safe to rely on the system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected ' UTC ' for ' 8.0/no DST ' instead in '
Such a mistake. How to fix it?
In fact, from PHP 5.1.0, when a function such as date () is used, if timezone is set incorrectly, E_notice or e_warning information is generated every time the function is called. And in php5.1.0, date.timezone this option, by default, is off, no matter what the PHP command is Greenwich Mean time, but the PHP5.3 seems to be forced to throw the error if there is no setting, to solve this problem, as long as the localization, it is OK.
Here are three ways to do it (any one of them):
First, use Date_default_timezone_set () to set Date_default_timezone_set (' PRC ') on the page header; East Eight time zone echo date (' y-m-d h:i:s ');
Second, use Ini_set (' Date.timezone ', ' Asia/shanghai ') in the head of the page;
Third, modify the php.ini. Open Php5.ini Find Date.timezone Remove the previous semicolon modification to become: Date.timezone =PRC
Restart the HTTP service (such as Apache2 or IIS).
XXX can be any correct value. For our country: can be the following values: Asia/chongqing, Asia/shanghai, Asia/urumqi (Chongqing, Shanghai, Urumqi, respectively) Taiwan available: Asia/macao, Asia/hong_kong, asia/ Taipei (Macao, Hong Kong, Taipei) and Singapore: Asia/singapore, and of course PRC.
PHP warning:date () [function.date]: It is not safe for rely on the system ' s timezone