当运行一些程序时,在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. Django中settings设计模式(单例模式)

    配置文件: 需求:配置文件,默认配置和手动配置分开,参考django的配置文件方案,默认配置文件放在项目容器内部,只让用户做常用配置. /bin/settings.py(手动配置) PLUGIN_IT ...

  2. 013-- mysql常用的查询优化方法

    浅谈MySQL中优化sql语句查询常用的30种方法   1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句 ...

  3. 《Pro SQL Server Internals, 2nd edition》的CHAPTER 1 Data Storage Internals中的Data Pages and Data Rows(翻译)

    数据页和数据行 数据库中的空间被划分为逻辑8KB的页面.这些页面是以0开始的连续编号,并且可以通过指定文件ID和页号来引用它们.页面编号都是连续的,这样当SQL Server增长数据库文件时,从文件中 ...

  4. linux一切皆文件之文件描述符(一)

    一.知识准备 1.在linux中,一切皆为文件,所有不同种类的类型都被抽象成文件.如:普通文件.目录.字符设备.块设备.套接字等 2.当一个文件被进程打开,就会创建一个文件描述符.这时候,文件的路径就 ...

  5. 三羊献瑞:dfs / next_permutation()

    三羊献瑞 观察下面的加法算式: 祥 瑞 生 辉  +   三 羊 献 瑞-------------------   三 羊 生 瑞 气 (如果有对齐问题,可以参看[图1.jpg]) 其中,相同的汉字代 ...

  6. EF多个上下文迁移

    步骤: 1. Enable-Migrations 2. add-migration Initial -ConfigurationTypeName ModelOneDbConfig 3. update- ...

  7. 最新!2016中国城市GDP排名出炉

    2017年1月20日,国家统计局公布:2016年中国国内生产总值GDP达744127亿元,同比增长6.7%,城市GDP方面:截至1月20日,全国大部分城市的去年经济运行数据已经公布,根据信息汇总,20 ...

  8. Rotation and Transform

    A transformation matrix describes the rotation of a coordinate system while an object remains fixed. ...

  9. Flexbox + js实现滑动拼图游戏

    滑动拼图就是把一张图片分成几等份,打乱顺序(下图),然后通过滑动拼凑成一张完整的图片. 要实现一个拼图游戏,需要考虑怎样随机的打乱顺序,怎样交换两张图片的位置,等等.但是,使用了Flexbox布局以后 ...

  10. js备忘录3

    JavaScript也有类型转换 js中的获取指定位数的方法 +和-的转换方向不同 在JavaScript中首先给变量赋值数字,然后再给变量赋值字符串是合法的 这点和Java有些区别 在函数体内声明变 ...