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

 

原文地址:https://www.cnblogs.com/waw/p/9690029.html