Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timezone conversion on strings #4546

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from

Conversation

PrinsFrank
Copy link

@PrinsFrank PrinsFrank commented Jan 20, 2025

When setting a default application timezone, and a display timezone:

date_default_timezone_set('UTC');
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris');

Date objects get converted, but strings don't. See #4545.

For most other paths in convertDate, the dateTime object is initialized, and afterwards the timezone gets set. For strings, the timezone is passed as a constructor argument before having the timezone set again, losing its converting behaviour. This makes the convertDate method work identical for DateTime objects as strings. This different behaviour was already spotted in #3568.

Fixes #4545 #3568 #2819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Automatic timezone conversion from date_default_timezone to CoreExtension timezone broken for strings
1 participant