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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?