在执行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 still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in /usr/local/apache/htdocs/test.php on line 50 。

Cause: 
   这是因为PHP所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差8个小时左右,我们可以按照下面的方法解决。

解决办法:

1、在页头使用date_default_timezone_set()设置我的默认时区为北京时间,即

<?php

date_default_timezone_set("PRC");

?>就可以了。

2、在php.ini中设置date.timezone的值为PRC,设置好以后的为:date.timezone=PRC,同时取消这一行代码的注释,即去掉前面的分号就可以了。

转载于:https://www.cnblogs.com/chuangshaogreat/p/7878982.html

Warning: date() :It is not safe to rely on the system's timezone settings相关推荐

  1. Warning:It is not safe to rely on the system's timezone settings

    今天在本地运行PHP脚本文件没有问题,但是传到线上测试服务器以后,报了如下错误:<b>Warning</b>: date() [<a href='function.dat ...

  2. 问题解决:Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You.

    在我们使用到时间函数data()时,有时候会弹出下面这种错误: "PHP Warning: date() [function.date]: It is not safe to rely on ...

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

    在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个 "PHP Warning: date() [function.date]: It is not safe to rely on ...

  4. PHP Warning: date(): It is not safe to rely on the system’s timezone settings

    如下错误: PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *requir ...

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

    OSSEC安装结束后运行,运行以下命令却抛错 cat /opt/ossec/logs/alerts/alerts.log 具体抛错内容: ** Alert 1468897672.2164786: ma ...

  6. Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use

    运行php文件报错如下: Warning: date(): It is not safe to rely on the system's timezone settings. You are *req ...

  7. php : Warning: strftime(): It is not safe to rely on the system's timezone settings.

    使用 Smarty 的时候出现这种警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. ...

  8. php echo输出多了 date(): It is not safe to rely on the system‘s timezone settings

    原因 如果使用PHP5.3以上版本时,如果没有正确的配置php.ini就会出现PHP日期函数的错误.以前很多旧的PHP编程教程没有说到这个问题,所以不少读者会觉得困惑,下面笔者为大家讲述解决这个问题的 ...

  9. php Warning: phpinfo(): It is not safe to rely on the system's timezone settings.解决方法

    安装php后,使用phpinfo();查看信息,有Warning: phpinfo(): It is not safe to rely on the system's timezone setting ...

最新文章

  1. 英文字典设计c语言代码,一种简单的英文词典排版系统
  2. [转]asp.net权限认证:HTTP基本认证(http basic)
  3. AI:一个20年程序猿的学习资料大全—人工智能之AI/机器学习/深度学习/计算机视觉/Matlab大赛——只有你不想要的,没有你找不到的
  4. javaee和javaee_JavaEE概念简介
  5. uvm 形式验证_IC设计职位详解之“数字验证工程师”就业必学课程
  6. GCD之后台程序运行
  7. [转载] python判断字符串中包含某个字符串_干货分享| Python中最常用的字符串方法
  8. python文件拷贝到其他盘符_Python:文件操作技巧(File operation)
  9. 修炼成QTP高手的十个步骤
  10. oracle报错12516,Oracle连接数太多报错-ORA-12516异常
  11. K650c + Ubuntu 15.04无法正常关机,重启
  12. 运维是做什么的?史上最全互联网Linux工作规划!十分钟找到linux运维工程师职业方向!...
  13. Linux基础知识-1
  14. Oracle 常见错误总结及问题解决方法
  15. 微擎url模式解读_微擎常用开发文档
  16. greasemonkey_Greasemonkey –在任何页面上执行自定义JavaScript
  17. 什么是HTAP 阿里云上实现
  18. c++ 复合类型 读书笔记(二)
  19. 关于idea+mybatis+springcloud+swagger2+Apollo 踩得小坑
  20. 视网膜血管分割方法整理

热门文章

  1. 数据分析师三个等级_【数据分析课|这三个等级的数据分析师报考条件,一定是你需要的】- 环球网校...
  2. showModalDialog传值
  3. mysql创建触发器
  4. Give Us the Money
  5. AndroidP HIDL 转载
  6. 前端加密中文,后端解密java
  7. 解决声卡爆音/杂音的四种方法
  8. 安移通(ARUBA)WiFi短信验证:无线上网热点短信认证设置流程
  9. 信锐无线控制器短信认证企信通配置
  10. 月薪过万的程序员都培训的什么编程语言?