2015-05-21 11:11
浏览 77

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"

图片转代码服务由CSDN问答提供 功能建议


严格警告:依赖系统的时区设置是不安全的。 请使用date.timezone设置,TZ环境变量或date_default_timezone_set()函数。 如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符。 我们为'UTC / 0.0 /无DST'选择'UTC'而不是


  DateTime :: createFromFormat('U.u',sprintf('%。6F',microtime(true)),new DateTimeZone('UTC')); 
 <  p>奇怪的是我已经使用UTC作为时区,但它仍然会输出此警告。 我怎么能摆脱这个? 

我在Debian Wheezy上运行php 5.6。

我所有的php.ini文件都包含以下内容< code> date.timezone 设置。

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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题