php专区

 首页 > php专区 > PHP高级 > 日期 > PHP Warning: date(): It is not safe to rely on the system -

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

分享到:
【字体:
导读:
          昨天碰到使用date()函数时出现PHP Warning: date(): It is not safe to rely on the system出现这种错误是因为php5默认date tim...

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

昨天碰到使用date()函数时出现PHP Warning: date(): It is not safe to rely on the system出现这种错误是因为php5默认date.timezone为utc,改为date.timezone = PRC即可.下面看我的方法总结。

在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这行,改成如下:date.timezone = Asia/Shanghai,然后重启apache即可!

在php程序中解决,在你程序前加上如下代码:

date_default_timezone_set('asia/shanghai');或者

ini_set('date.timezone','asiashanghai');

 
分享到:
php中两日期比较程序代码 - php日期
php中两日期比较程序代码 其实在php中比较两个日期有很多方法,我最常用的就是把日期利用strtotime函数把它转换成数字,然后进行加减了,下面看实例。 实例一:   实例二:  
php中timezone时区设置方法 - php日期
php中timezone时区设置方法 如果使用的是独立的服务器,有权限修改配置文件,设置时区就可以通过修改php.ini中的date.timezone属性完成。我们可以将这个属性的值设置为\"Asia/Shang\"、\"Asia/Chongqing\"、\"Etc/GMT-8\"或PRC等中的一个,再在PHP脚本中获取的当前时间就是北京时间。修改PHP...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……