duanqiao1961 2015-05-21 11:11
浏览 87
已采纳

PHP 5.6 DateTime严格警告时区UTC

I'm currently getting following STRICT warning when creating a UTC datetime from php.

Strict Warning: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 'UTC/0.0/no DST' instead

This is the line of code I'm using.

DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), new DateTimeZone('UTC'));

The strange thing is I'm already using UTC as timezone, but it still outputs this warning. How can I get rid of this?

I'm running php 5.6 on Debian Wheezy.

All my php.ini files contain the following date.timezone setting.

date.timezone = "Europe\Amsterdam"

  • 写回答

1条回答 默认 最新

  • dongpu1331 2015-05-21 13:21
    关注

    Seems I had missed one php.ini file + including the fix (forward slash) as suggested by @Ofir-Baruch it seems to be solved.

    The php.ini I forgot was the hhvm one.

    It failed on console lines since I configured all console php to be executed by hhvm using following command.

    /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60

    I forgot about that and figured that out when I echo'd following.

    echo phpinfo(); which returns Hip Hop in case of hhvm.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料