Review main Ready for review

95136[BUGFIX] Respect timezone of date object in DateFormatter

Maik Schneider CR -1 V +1 Normal +43 −14 updated 11/10/26, 07:32

Commit message

DateFormatter::format() instantiated IntlDateFormatter without a
timezone, so the formatter silently fell back to the default timezone
of the PHP process and discarded the timezone carried by the given
date object.

This surfaced with <f:format.date pattern="..."> which routes through
DateFormatter, while the "format" argument uses DateTime::format() and
was therefore unaffected. All named and numeric formats were affected
in the same way.

The timezone is now resolved once from the given date object and always
passed to IntlDateFormatter

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/36/95136/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/36/95136/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Marco Huber +1
    • Benni Mack -1
    • Simon Schaufelberger +1
    • Andreas Wolf +1
  • Verified V +1 Needs a vote
    • Marco Huber +1
    • Simon Schaufelberger +1
    • Andreas Wolf +1
    • core-ci +1 CI

Merge conflicts 1

Issues 1

Files 2

Review log 68

  1. Maik Schneider uploaded patch set 1 08/06/26, 19:38

  2. Maik Schneider updated the commit message in patch set 2 08/06/26, 19:40

  3. core-ci voted on patch set 1 V +1 08/06/26, 19:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106033

  4. core-ci voted on patch set 2 V +1 08/06/26, 19:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106034

  5. Andreas Wolf voted on patch set 2 CR +1 V +1 08/06/26, 20:23

  6. Marco Huber voted on patch set 2 CR +1 V +1 08/06/26, 20:34

  7. Simon Schaufelberger voted on patch set 2 CR +1 V +1 11/06/26, 00:50

  8. Benni Mack commented on patch set 2 CR -1 11/10/26, 07:32

    Unresolved

    Thanks for picking this up, and the direction is right: format() now behaves like strftime() in the same class, which already passes the date's timezone. The new test fails without the fix and passes with it (checked locally on PHP 8.5). There's one problem I'd like fixed before merging: Passing $date->getTimezone() to IntlDateFormatter throws an IntlException for timezones that ICU doesn't recognise, namely those stored as an abbreviation or as "Z". ISO-8601 strings ending in "Z" are very common, for example from APIs or imports into Extbase models. If such an object reaches <f:format.date pattern="...">, it used to render (in the wrong timezone) and now ends in an uncaught exception. Could you fall back to the fixed offset when ICU can't handle the zone, e.g. 'GMT' . $date->format('P'), and add a "Z" and a "CEST" case to the data provider? strftime() has the same problem already, so fixing both together would make sense.