zoukankan      html  css  js  c++  java
  • PHP Warning: strftime(): It is not safe to rely on the system's timezone set

    当运行一些程序时,在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"。

  • 相关阅读:
    samba 服务搭建
    lock
    dev GridControl FilterCriteria
    dev GridControl Column 背景色
    Microsoft NLayerApp案例理论与实践
    DDD
    .Net架构师-开闭原则
    .Net架构师-面向对象的设计原则
    .Net架构师-详解面向对象
    .Net架构师-面向过程和面向对象
  • 原文地址:https://www.cnblogs.com/chenzc/p/4079286.html
Copyright © 2011-2022 走看看