我在 debian 8 上使用 php 5.6.17。设置 owncloud 后,我注意到由 owncloud(不是 apache)自己编写的日志有错误的时区。
我对此进行了一些调查,似乎该行:
DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), 'Europe/Berlin');
Run Code Online (Sandbox Code Playgroud)
这不关心任何时区设置。而不是欧洲/柏林 (+1/+2) 的时间,我总是得到 UTC 的时间。
在/etc/php5/apache2/php.ini我设置"date.timezone = "Europe/Berlin"和系统时间(debian)也是正确的。
即使我运行类似下面的东西,我也会得到相同的输出(UTC):
$time=DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), new DateTimeZone('UTC'));
echo $time->format('c') . "\n";
$time=DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), new DateTimeZone('Europe/Berlin'));
echo $time->format('c') . "\n";
Run Code Online (Sandbox Code Playgroud)
关于这个问题的任何想法?