Skip to content

[Form] Date field in Form type shows the wrong date #5536

@i4got10

Description

@i4got10

This thing explained here #3673.
I have a date field in my entity and form for it.
in database: 31.10.2011
at form: 30.10.2011
symfony 2.1.1-DEV
my timezone set to "Asia/Yekaterinburg" in php.ini

Problem somewhere at this lines at DateTimeToLocalizedStringTransformer

        echo $dateTime->format('d.m.Y H:i:s T');
        // convert time to UTC before passing it to the formatter
        $dateTime = clone $dateTime;
        if ('UTC' !== $this->inputTimezone) {
            $dateTime->setTimezone(new \DateTimeZone('UTC'));
        }
        echo $dateTime->format('d.m.Y H:i:s T');

31.10.2011 00:00:00 YEKT
30.10.2011 18:00:00 UTC

Why do symfony convert date to UTC before being shown it in the form

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