Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] DST issues in TimeType #7187

Copy link
Copy link
Closed
Closed
Copy link
@Maxwell2022

Description

@Maxwell2022
Issue body actions

I have a field from an entity that is a time type (Doctrine type). So when I save a time in the database (through Symfony 2.1.7 using Form) it save the data in the following format:

HH:mm:ss ie. 13:30:00

This time is save in UTC using the model_timezone option. When fetching the data from the database, it display the time back in the user timezone thanks to view_timezone option.

If I'm right, this is performed thanks to the data transformer: DateTimeToStringTransformer

Here is my full field definition:

$builder
    ->add('time', 'time', array(
        'widget' => 'single_text',
        'label' => 'form.time',
        'translation_domain' => 'AcmeDemoBundle',
        'error_bubbling' => true,
        'attr' => array('class' => 'time-picker'),
        'model_timezone' => 'UTC',
        'view_timezone' => $this->options['user_timezone']
    ))
    ;

The problem is the following: I think because the date is not saved in the database, the Datetime object is built using the a default date which is 1970-01-01. When converting the time in the user timezone, the Datetime object is calculating the difference regarding the daylight saving of the Jan 1st, 1970 which is not returning the excepted time.

ie. I enter 03:00 using America\Los_Angeles timezone, it's saving 11:00 in the database which is correct. But when reloading the form, it display 02:00 (-1 hour daylight saving). I would expect to get the same data I've entered previously in the form which means 03:00

Useful tool to see timezone's time correspondance: http://www.worldtimebuddy.com/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.