PHP警告date(): It is not safe to rely on the system

大体是说timezone没有设置,在中国使用的是格林+8小时,所以需要设置一下。

第一种

在页面头部加入以下语句

 代码如下 复制代码

 date_default_timezone_set("PRC");  或 ini_set('date.timezone','asiashanghai');

这种方法有个缺点,就是所有的页面都得添加

第二种

在php.ini里找到date.timezone这行,把值改成PRC,如

 代码如下 复制代码

date.timezone = PRC。

如果没有这一行直接加上就好。最后重启WEB服务器与PHP即可。

友情提示:实际上,从 PHP 5.1.0 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是PHP5.3中好像如果没有设置也会强行抛出了这个错误的,解决此问题,只要本地化一下,就行了。

时间: 2024-10-28 02:00:43

PHP警告date(): It is not safe to rely on the system的相关文章

PHP Warning: date(): It is not safe to rely on the system

在php程序中运行时报如下警告信息: 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      主要是时区没有设置的缘故,调整很简单, 打开php.ini文件,并找到date.timezone这行,

PHP date()函数警告: It is not safe to rely on the system解决方法_php实例

近来总是有系统邮件提示,开始没在意,后来不断提示就看了一下.提示以下信息 复制代码 代码如下: 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 t

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

解决php的It is not safe to rely on the system’s timezone settings

  在写php程序中有时会出现这样的警告: 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 st

解决php的“It is not safe to rely on the system’s timezone settings”问题_php技巧

如果使用PHP5.3以上版本时,如果没有正确的配置php.ini就会出现PHP日期函数的错误.以前很多旧的PHP编程教程没有说到这个问题,所以不少读者会觉得困惑,下面笔者为大家讲述解决这个问题的三种方法."PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date. timezone setting

php date(): It is not safe 警告解决

 升级php版本从PHP5.2.17 到 PHP 5.3.21 后出现如下保存  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

关于php程序报date()警告的处理(date_default_timezone_set)_php技巧

在写php程序中有时会出现这样的警告: 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 stil

php程序中报date错误

在写php程序中有时会出现这样的警告: 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 stil

安装Prosper202程序出现Warning: date()错误提示问题

今天有帮助客户安装Prosper202程序的时候,采用客户习惯的WDCP面板,然后在部署Prosper202设置数据库文件,以后打开安装向导都比较简单,但是在安装完毕之后,看到在登录界面有很多错误的脚本提示.     原本想侥幸首页没有问题,只要能登录进入就可以,但是登录后依旧不行,看来是需要解决问题了.   第一.错误提示问题    代码如下 复制代码 Warning: date(): It is not safe to rely on the system's timezone settin