Project

General

Profile

Actions

Bug #92050

closed

Wrong localized dates in f:format.date viewhelper

Added by Christian Toffolo over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2020-08-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Feature #92760: extend f:format.date with an optional argument for to convert date to an current TimezoneUnder Review2020-11-03

Actions
Actions #1

Updated by Oliver Hader over 3 years ago

Good catch, to me it seems like

  • f:format.date should get an additional attribute timezone which is null per default and uses the default timezone
  • the timezone offset as given/resolved in attribute timezone then has to be added to the unixtime representation (which UTC)
  • this also would allow to show times for different timezone (e.g. based on individual user settings)
Actions #2

Updated by Henrik Ziegenhain over 2 years ago

This is a duplicate of #92760

The patch from the mentioned issue is working fine and behaves as stated out by Oliver, but I think it is only mergable to v11 and v12

Actions #3

Updated by Georg Ringer over 2 years ago

  • Related to Feature #92760: extend f:format.date with an optional argument for to convert date to an current Timezone added
Actions #4

Updated by Georg Ringer over 2 years ago

  • Status changed from New to Closed

closed as duplicate

Actions

Also available in: Atom PDF