Issue Bug Closed

#98045DateAspect->getTimezone (almost) never returns the correct value

Jan Delius 07/28/22, 11:47 updated 03/28/25, 10:03

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