Project

General

Profile

Actions

Bug #98045

closed

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

Added by Jan Delius almost 2 years ago. Updated 27 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2022-07-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #103588: PreviewSimulator for time restricted pagesResolved2024-04-10

Actions
Related to TYPO3 Core - Bug #103690: Preview of page in the past (expired) throws exceptionClosed2024-04-20

Actions
Has duplicate TYPO3 Core - Bug #99627: Context:class don't detect timezone correctlyResolved2023-01-19

Actions
Actions

Also available in: Atom PDF