php timezone: DateTime::createFromFormat ignores timezone

Viewed 2718

I'm using php 5.6.17 on debian 8. After set up owncloud, I noticed, that the logs which are self written by owncloud (not by apache) has wrong time zones.

I investigated this a bit, seems like, that the line:

DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), 'Europe/Berlin');

This does not care about any timezone setting. Instead of the time for Europe/Berlin (+1/+2) I get always the time for UTC.

In /etc/php5/apache2/php.ini I set "date.timezone = "Europe/Berlin" and the system time (debian) is also correct.

Even If I run somthing like below I get the same output (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";

Any ideas about this problem?

2 Answers
Related