网站地图    收藏   

主页 > php专栏 > php函数大全 >

PHP中date函数date(): It is not safe to rely - php函数

来源:自学PHP网    时间:2014-11-25 00:26 作者: 阅读:

[导读] 今天在php直接使用date函数会发现提示date():It is not safe to rely...错误了,提示是不是一个安全的用法,那么要如何解决此问题呢.在PHP代码中调用date函数时,在日志里看到如下报错:PHP Warn......

PHP中date函数date(): It is not safe to rely

今天在php直接使用date函数会发现提示date():It is not safe to rely...错误了,提示是不是一个安全的用法,那么要如何解决此问题呢.

在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//phpfensi.com

为什么会出现这样的报错?

从 PHP 5.1.0 引用了时区设置(date.timezone),但其默认又是关闭的,所以使用date()等函数时,都会产生E_NOTICE 或者 E_WARNING 信息.

处理方法,在调用date前加入下代码:

在页头加入代码:ate_default_timezone_set("PRC");

在页头加入代码:ini_set('date.timezone','注释:RPC');

在php.ini中启用date.timezone设置并设置其值,date.timezone=PRC,并重启apache.

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论