'How can I avoid datetime problems in TYPO3?

I have created a little extension which uses datetimes to view some specific events (event date and event time), but I always run into trouble if I try to get the correct datetime from database to frontend.

I can set the datetime for each event via TYPO3 backend:

enter image description here

But if I try to get this value on frontend like:

<f:format.date format="d.m.Y - H:i:s">{event.appointment}</f:format.date>

Then the output is not "10.04.2016 - 08:00:00" it is "10.04.2016 - 10:00:00".

How can I avoid this behaviour? I have set the timezone via install tool too:

[SYS][phpTimeZone] = Europe/Berlin

but I get always the wrong datetime. If I try something like this:

DebugUtility::debug(new \DateTime());

then I get the correct output:

{"date":"2016-04-09 20:23:38.000000","timezone_type":3,"timezone":"Europe\/Berlin"}

If I take a look at the database I can see that the correct datetime is stored:

enter image description here

So I don't know why I got the wrong datetime, any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source