当运行一些程序时,在httpd日志中会有如下警告日志:

PHP Warning:  strftime(): 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'。。。。。。。。。。。

  • 原因分析:
      这是因为PHP默认是以格林威治标准时间(UTC)为准进行时间转换,因为自己所处的当地时间与UTC会有出入,格林威治标准时间和北京时间有8个小时的时间差。因此我们必须为PHP指定一个时区,让php知道以哪个时区为准进行转换。

  • 解决办法:

    1. 在你的PHP程序头部使用date_default_timezone_set()设置我的默认时区为北京时间(PRC,中国的英文缩写),即  <?php     date_default_timezone_set("PRC");   ?>就可以了。这种方法使用时太复杂,必须在每个使用date的文件中添加相关函数,下面的方法更简单方便。

    2. 在php.ini中找到date.timezone行,支持前面的';'号(如果没有修改过的话应该是没有启动此选项的),并将它的值设置为PRC,设置好以后为:date.timezone="Asia/Shanghai"。

PHP Warning: strftime(): It is not safe to rely on the system's timezone set的更多相关文章

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

    当运行程序时,会出现如下警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. You a ...

  2. 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. ...

  3. [服务器时区问题]PHP Warning: strftime(): It is not safe to rely on the system's timezone set

    PHP Warning: strftime(): It is not safe to rely on the system's timezone set 当运行一些程序时,在httpd日志中会有如下警 ...

  4. 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 ...

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

    错误描述: PHP Warning:  phpinfo(): It is not safe to rely on the system's timezone settings. You are *re ...

  6. php时区设置 warning: strtotime(): It is not safe to rely on the system's timezone settings

    warning: strtotime(): It is not safe to rely on the system's timezone settings warning: strtotime(): ...

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

    错误截图 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* t ...

  8. 出现Warning: date(): It is not safe to rely on the system's timezone settings的解决办法

    在没有配置,尤其是新安装的PHP中使用date函数时,会报这个错误: Warning: date(): It is not safe to rely on the system's timezone ...

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

    有三种解决办法: 1. php文件中设置时区 <?php date_default_timezone_set('Asia/Shanghai'); echo strtotime('2012-9-3 ...

随机推荐

  1. Win环境 Android Studio使用Git 教程 ( 一 )

    一. 安装 下载安装完成Git后 进入命令行 输入命令git --version,如果能显示版本则说明安装成功,如果没有显示版本,需要配置环境变量: 在path中添加git的安装位置 二 . 配置信息 ...

  2. 廖雪峰git教程学习笔记3

    commit是一串不便记忆的数字,为了方便记忆,引入tag,tag就跟HEAD一样,就像一个指针,指向commit,且指向是不能变得,一个commit就有一个tag 给当前分支下的当前commit打上 ...

  3. JS对象,获取key和value

    var peopleArray=[] var peopleobj={jiangyx: "姜艳霞", yeluosen: "叶落森"} for(let i in ...

  4. 跨域Ajax -- jsonp和cors

    跨域Ajax - jsonp - cors 参考博客: http://www.cnblogs.com/wupeiqi/articles/5703697.html http://www.cnblogs. ...

  5. OO第四次作业-对前三次作业总结

    第一次作业由于直接没怎么学过java,全靠一星期速成,前几天看了java的语法,但是因为光看没有打代码,学习效果并不是特别好.由面向过程转向面向对象,不是特别清楚该怎么办,虽然写的是两个类,但实际上是 ...

  6. 我现在对Git的认识

    由于时间关系,我还没能真正的了解什么是Git,只是大致的了解了一下,并且在网上查阅了资料,做了一些总结,以便进一步研读. Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项 ...

  7. my everying

    evering -> everything 一.请回望暑假时的第一次作业,你对于软件工程课程的想象 1)对比开篇博客你对课程目标和期待,"希望通过实践锻炼,增强计算机专业的能力和就业竞 ...

  8. Leetcode题库——13.罗马数字转整数

    @author: ZZQ @software: PyCharm @file: Luoma2Int.py @time: 2018/9/16 17:06 要求: 罗马数字转数字 字符 数值 I 1 V 5 ...

  9. HDU 4418 Time travel 期望dp+dfs+高斯消元

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4418 Time travel Time Limit: 2000/1000 MS (Java/Othe ...

  10. HTML和CSS <h1> --1-- <h1>

    Html和CSS的关系 学习web前端开发基础技术需要掌握:HTML.CSS.JavaScript语言.下面我们就来了解下这三门技术都是用来实现什么的: 1. HTML是网页内容的载体.内容就是网页制 ...