#68651Datetime() properties have wrong timezone
Description
Summary:
The TYPO3 backend does it right. Would be great to have Extbase doing right as well!
Details:
My timezone is set to “Europe/Berlin” (‘phpTimeZone’ => ‘Europe/Berlin’)
In the backend everything is ok: I can enter “31-10-2015 00:00” in a field ‘firstDay’ and it’s always correct. But in the frontend, with Extbase/Fluid and
<f:format.date format="d.m.Y">{offer.firstDay}</f:format.date>`
I will see “30.10.2015” as output, because that date has been calculated for timezone GMT/UTC, which is “30-10-2015 22:00” which is 2 hours less than our current CEST (central european summer time).
The problem is, that Extbase instantiates the offer.firstDay DateTime() object with timezone_type => 1:
object(DateTime)[1] public 'date' => string '2015-10-30 22:00:00' (length=19) public 'timezone_type' => int 1 public 'timezone' => string '+00:00' (length=6)
while it actually needs the correct timezone information.
I can correct that in the following manner:
// we use $now to copy the timezone from $now = new \DateTime(); firstDay->setTimeZone($now->getTimezone());
After that procedure var_dump($firstDay) says:
object(DateTime)[1] public 'date' => string '2015-10-31 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Berlin' (length=13)
And now $firstDay will give the same result that the backend gives for
<f:format.date format="d.m.Y">{offer.firstDay}</f:format.date>`
The result is now the expected “31.10.2015”.
Earlier discussions
When searching for a solution I found an earlier discussion of that issue here: http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2010-July/006013.html
Reviews 2
Related issues 8
- Bug #68849Unstable persistence handling of DateTime (don't get what you set)
- Bug #72878wrong datetime handling, they are not UTC in db
- Bug #79613Saving wrong Date into DB if Field is of type DATE
- Bug #80008Avoid warning dialog when closing records with start-, endtime values
- Bug #80349Extbase mapping of \DateTime for integer values does not set timezone with region string but only offset
- Feature #80559datetime and time handling should always have timezone information
- Bug #80679Input field eval datetime in FlexForm converts to wrong timestamp
- Bug #106467Align extbase DateTime handling to FormEngine