Issue Bug Closed

#92050Wrong localized dates in f:format.date viewhelper

Christian Toffolo 08/19/20, 14:06 updated 01/12/22, 10:03

Description

To reproduce this bug use the f:format.date viewhelper like:

<f:format.date format="%d. %B %Y">{dateObject}</f:format.date>

With a dateObject like:

DateTime Object (
    [date] => 2020-01-01 00:00:00.000000
    [timezone_type] => 1
    [timezone] => +02:00
)

Wrong result: 31. December 2019
Expected: 01. January 2020

I guess the problem is in this line:
https://github.com/TYPO3/TYPO3.CMS/blob/383622db19d67eb74ccbac4fa9aa24319db3ef59/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php#L167
because $date is converted in Epoch Unix Time Stamp not considering time zone.

With the above data, $date->format(‘U’) equals 1577829600 that Is equivalent to 12/31/2019 @ 10:00pm (UTC) that returns the localized month name of December instead of January.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.