最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP中date函数date(): It is not safe to rely
时间:2014-04-24 编辑:简简单单 来源:一聚教程网
在PHP代码中调用date函数时,在日志里看到如下报错
PHP Warning: 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead
为什么会出现这样的报错?
从 PHP 5.1.0 引用了时区设置(date.timezone),但其默认又是关闭的,所以使用date()等函数时,都会产生E_NOTICE 或者 E_WARNING 信息。
处理方法1
在调用date前加入下代码
在页头加入代码:ate_default_timezone_set("PRC");
在页头加入代码:ini_set('date.timezone','注释:RPC');
在php.ini中启用date.timezone设置并设置其值:date.timezone=PRC,并重启apache;
注释:RPC代表中华人民共和国。
-
上一个: linux中给php添加扩展方法
-
下一个: php上传cvs文件完整例子