使用php-5.3或者更高版本时,如果按照默认配置,涉及到时间函数时,会报类似如下waring信息:
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. [include/page_header.php:145]
解决办法如下:
修改php.ini。查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC即可,有的资料介绍还可以按照如下两种方法解决
1.在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');
2. 在页头使用 ini_set('date.timezone','Asia/Shanghai');
对于我们国内来说:可以为以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,当然PRC也行。
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. [include/page_header.php:145]
解决办法如下:
修改php.ini。查找date.timezone 去掉前面的分号修改成为:date.timezone =PRC即可,有的资料介绍还可以按照如下两种方法解决
1.在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');
2. 在页头使用 ini_set('date.timezone','Asia/Shanghai');
对于我们国内来说:可以为以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,当然PRC也行。
编辑回复