Skip to content
Snippets Groups Projects
user avatar
Markus Klein authored
As documented by PHP, `\DateTime` or `\DateTimeImmutable`
objects created with a timestamp only ('@12345678') as the
first constructor argument will use UTC as TimeZone.

Creating an object instance without any constructor arguments
will use the `date_default_timezone_get()` timezone for the
object - and setting the timestamp using `setTimestamp()` will
not change the object's timezone.

That means, that formatting the value will be done using
the object Timezone and **NOT** the default PHP Timezone
(`date_default_timezone_get()`).

Consequently, this may lead to wrong interpretation of
the displayed formatted value in the context of another
timezone - if no timezone information (+0000/-0100) is
included.

This change streamlines this for a couple of places were
it is expected to format date, datetime or time values
for the current context timezone by ensuring objects get
the current timezone set instead of `UTC`.

Note: Changing the date default timezone on the fly after
an object has been created will show a similar effect like
using constructor values, even if the object has been
created by using the `setTimestamp()` method.

[1] https://3v4l.org/sGEe2

Resolves: #98045
Resolves: #99627
Releases: main, 12.4, 11.5
Change-Id: I095a0b0b376361e25396647d02727ac08f35cae0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81915


Tested-by: default avatarGarvin Hicking <gh@faktor-e.de>
Reviewed-by: default avatarGarvin Hicking <gh@faktor-e.de>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarAndreas Wolf <andreas.wolf@typo3.org>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
5079949f
Name Last commit Last update