Search code examples
mysqldatetimetypo3fluid

Correct timezone handling with TYPO3 and Fluid


Its confusing me. I've a property in my Model which is annotated with DateTime. In my Database its stored as timestamp. In Frontend I use the f:format.date viewhelper to output this property.

When I create a new record, and add f.e. 01.06.2017 10:00 in this field, in my database is stored the timestamp for 01.06.2017 08:00. In Frontend the output is correct. Until here everything is fine.

The last timechange in March lead to a + of two hours in output. I assume in October that will change again and the output will be than this: 01.06.2017 08:00.

How can I prevent this. Its definitely a problem when these dates change, because its important for the business.

How can I test what will happen in October?


Solution

  • The Problem occurs as TYPO3 saves times normalized as UTC. for normalization (and afterwards denormalization) it respects the timezone-settings of the server. Or settings given in LocalConfiguration.php.
    Up to 6.2 there were two settings [SYS][serverTimeZone] and [SYS][phpTimeZone].
    With 7.6 it is only [SYS][phpTimeZone] as the servertimezone is detected from php itself.

    You now have the option to fake the timezone of your server to "UTC" by setting [SYS][phpTimeZone] to the string "UTC". In this way no times should be changed any more.