我正在使用Debian 8上的PHP 5.6.17。在设置ownCloud后,我注意到由ownCloud自行编写的日志(而非Apache编写)具有错误的时区。
我进行了一些调查,似乎是以下这行代码引起的问题:
DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), 'Europe/Berlin');
这不涉及任何时区设置。与欧洲/柏林(+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";
有关这个问题的任何想法?