[BUGFIX] Use correct timezones with timestamp based \DateTime
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:Garvin Hicking <gh@faktor-e.de> Reviewed-by:
Garvin Hicking <gh@faktor-e.de> Tested-by:
core-ci <typo3@b13.com> Tested-by:
Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by:
Andreas Wolf <andreas.wolf@typo3.org> Tested-by:
Stefan Bürk <stefan@buerk.tech> Reviewed-by:
Stefan Bürk <stefan@buerk.tech> Reviewed-by:
Oliver Klee <typo3-coding@oliverklee.de>
Showing
- Build/phpstan/phpstan-baseline.neon 0 additions, 5 deletionsBuild/phpstan/phpstan-baseline.neon
- typo3/sysext/adminpanel/Classes/Modules/PreviewModule.php 17 additions, 30 deletionstypo3/sysext/adminpanel/Classes/Modules/PreviewModule.php
- typo3/sysext/backend/Classes/Http/Application.php 6 additions, 1 deletiontypo3/sysext/backend/Classes/Http/Application.php
- typo3/sysext/backend/Classes/Routing/PreviewUriBuilder.php 5 additions, 2 deletionstypo3/sysext/backend/Classes/Routing/PreviewUriBuilder.php
- typo3/sysext/core/Classes/Console/CommandApplication.php 6 additions, 1 deletiontypo3/sysext/core/Classes/Console/CommandApplication.php
- typo3/sysext/core/Classes/Context/Context.php 6 additions, 1 deletiontypo3/sysext/core/Classes/Context/Context.php
- typo3/sysext/core/Classes/Localization/DateFormatter.php 2 additions, 2 deletionstypo3/sysext/core/Classes/Localization/DateFormatter.php
- typo3/sysext/core/Classes/Mail/MailMessage.php 1 addition, 1 deletiontypo3/sysext/core/Classes/Mail/MailMessage.php
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Reporting/Report.php 2 additions, 2 deletions...asses/Security/ContentSecurityPolicy/Reporting/Report.php
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Reporting/Resolution.php 1 addition, 1 deletion...s/Security/ContentSecurityPolicy/Reporting/Resolution.php
- typo3/sysext/core/Documentation/Changelog/12.0/Breaking-97091-TSFE-clear_previewHasBeenRemoved.rst 1 addition, 1 deletion.../12.0/Breaking-97091-TSFE-clear_previewHasBeenRemoved.rst
- typo3/sysext/core/Tests/Unit/Context/DateTimeAspectTest.php 16 additions, 0 deletionstypo3/sysext/core/Tests/Unit/Context/DateTimeAspectTest.php
- typo3/sysext/extensionmanager/Classes/Remote/TerExtensionRemote.php 1 addition, 1 deletion...xt/extensionmanager/Classes/Remote/TerExtensionRemote.php
- typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php 7 additions, 7 deletions...ysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php
- typo3/sysext/frontend/Classes/Http/Application.php 6 additions, 1 deletiontypo3/sysext/frontend/Classes/Http/Application.php
- typo3/sysext/frontend/Classes/Middleware/PreviewSimulator.php 1 addition, 6 deletions...3/sysext/frontend/Classes/Middleware/PreviewSimulator.php
- typo3/sysext/install/Classes/Http/Application.php 1 addition, 1 deletiontypo3/sysext/install/Classes/Http/Application.php
- typo3/sysext/install/Classes/Service/LanguagePackService.php 1 addition, 1 deletiontypo3/sysext/install/Classes/Service/LanguagePackService.php
- typo3/sysext/redirects/Classes/Repository/Demand.php 1 addition, 3 deletionstypo3/sysext/redirects/Classes/Repository/Demand.php
- typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php 3 additions, 3 deletions...cheduler/Classes/Controller/SchedulerModuleController.php
Please register or sign in to comment