V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fuxkcsdn
V2EX  ›  PHP

php.ini 里如何设置 Default timezone?不是设置 date.timezone

  •  
  •   fuxkcsdn · Apr 3, 2015 · 6644 views
    This topic created in 4042 days ago, the information mentioned may be changed or developed.
    今天给一台运行 CentOS 5.3 x86 的服务器 update 到 5.11,顺便把 php 从 5.2.x 升级到 5.3.29
    重启 web server 后,日志里就一直有这样的输出

    PHP Warning: Unknown: 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' instead in Unknown on line 0

    查看了下 php.ini ,发现是有设置 date.timezone 的啊
    然后 phpinfo 看了下,发现还有这样一设置选项
    Default timezone => Asia/Chongqing
    date.timezone => Asia/shanghai => Asia/shanghai

    把 php.ini 里的 date.timezone 改成 Asia/Chongqing ,重启 web server 就不再输出上面那个 warning 了,改回 Asia/shanghai 就马上又出现....
    找了下 php.net 的手册,没发现 php.ini 里有设置 Default timezone 的地方啊(还是我眼挫没看到)...


    P.S. CentOS 5 无法用 yum 升级到 CentOS 6 是吧?官方网站上不推荐这样升级
    Supplement 1  ·  Apr 4, 2015
    嗯...好吧...
    Asia/Shanghai 是不能写成 Asia/shanghai 的 Orz,刚还以为是系统时区问题
    /etc/localtime 设置的是 CST-8
    正打算把它改成 shanghai 的试试,ls -l /usr/share/zoneinfo/Asia/s[tab] 没反应,才想到会不会是大小写问题... Orz
    3 replies    2015-04-04 02:21:14 +08:00
    dearrrfish
        1
    dearrrfish  
       Apr 4, 2015
    你需要的是在bootstrap里加类似这一句?(猜的)

    // Force the timezone to UTC.
    date_default_timezone_set("UTC");
    yangqi
        2
    yangqi  
       Apr 4, 2015   ❤️ 1
    date.timezone就是Default timezone
    fuxkcsdn
        3
    fuxkcsdn  
    OP
       Apr 4, 2015
    @dearrrfish
    bootstrap 本来就有加这句了,5.2.x 时没提示,升级到 5.3.29才出现这提示的

    @yangqi
    是的,是我大小写没仔细看
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1829 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 16:22 · PVG 00:22 · LAX 09:22 · JFK 12:22
    ♥ Do have faith in what you're doing.