date_default_timezone_set()問題解決方案(PHP5.3以上的)


date() [<a href='function.date'>function.date</a>]: 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

 

 

這是由於調用date時,若timezone設置不正確所產生的E_NOTICE|E_WARNING錯誤

有以下幾種方案可解決該問題:

  1. 使用date_default_timezone_set()設置 date_default_timezone_set('PRC');
  2. ini_set('date.timezone','Asia/Shanghai');
  3. 修改錯誤級別配置(不推薦)
  4. 修改php.ini,顯式設置date.timezone=PRC

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM