#98045DateAspect->getTimezone (almost) never returns the correct value
Description
On the way the DateTimeAspect is initiated, there is never an evaluation of the current time zone. Thus the aspect always returns only the time zone “+00:00”. Also the ISO date is always given in UTC instead of the currently set server time zone.
An example of this is given in the method TYPO3\CMS\Frontend\Http\Application::initializeContext():
$this->context->setAspect('date', new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])));
A proof-of-concept code that makes the aspect return the correct values:
$dateTime = new \DateTime('@' . $GLOBALS['EXEC_TIME']);
$dateTime->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$this->context->setAspect('date', new DateTimeAspect(\DateTimeImmutable::createFromMutable($dateTime)));
This aspect is created in several places in the TYPO3 core. The value of date_default_timezone_get() is already defined beforehand by TYPO3 (if required) and should thus be able to be taken.
Apparently this bug has been present since the existence of the aspects until the current branch of the 12 version.
Reviews 10
- 13.4 88944[BUGFIX] Use DateTimeFactory for database datetime value interpretation
- main 88826[BUGFIX] Use DateTimeFactory for database datetime value interpretation
- 13.4 88901[BUGFIX] Apply server timezone to datetime properties in record API
- main 88823[BUGFIX] Apply server timezone to datetime properties in record API
- 11.5 83757[BUGFIX] Cast simulated timestamp to int
- 12.4 83756[BUGFIX] Cast simulated timestamp to int
- main 83742[BUGFIX] Cast simulated timestamp to int
- 11.5 83684[BUGFIX] Use correct timezones with timestamp based \DateTime
- 12.4 83682[BUGFIX] Use correct timezones with timestamp based \DateTime
- main 81915[BUGFIX] Use correct timezones with timestamp based \DateTime