Skip to content

[Form] Passing timezone settings from DateTimeType to DateType through model_timezone option #16518

@luads

Description

@luads

I came across an issue with daylight saving timezones where the day which changes the time is handled as a invalid date in PHP.

Since my form had a DateType field, I managed to fix this issue by setting both model_timezone and view_timezone to UTC. The same issue happened on a DateTimeType field, but setting the options didn't solve the error.

Looking further at the code, I realized that there's specific options been passed to the new DateType field created, and the timezone options aren't. This is the specific piece of code: https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php#L113

Adding model_timezone and view_timezone to this array solved my problem.

Am I missing something here, or this options should be passed to the DateType field?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions