date(): It is not safe to rely on the system's timezone settings.

回复 收藏
使用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也行。
2012-06-26 10:18 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: