Skip to content

3.4: Timezone wrong for Widgets #10877

@dereuromark

Description

@dereuromark

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.4

What you did

Normal recommended bootstrap of

// Internal UTC
date_default_timezone_set('UTC');

// Localized DE
ini_set('intl.default_locale', 'de_DE');

Type::build('time')->useLocaleParser();
Type::build('date')->useLocaleParser();
Type::build('datetime')->useLocaleParser();

And a CRUD for events - and use default dropdown selects for date time via DateTimeWidget.

What happened

The added event shows up in the DB as inputted (UTC), but should in fact be stored in UTC converted from local input. It is now 2 hours off.
The output via TimeHelper and outputTimezone option is properly converted from the UTC to GMT+2 value in view/index (even though now two hours off).
But this part of timezone adjustment for output is missing for add/edit and thus shows up wrong here.

What you expected to happen

The FormHelper and the Widgets must to the same transformation of +2 and -2 (for berlin anyway) just as the TimeHelper is doing. Otherwise localized times are stored and read wrong for Forms.

This fixes the issue for display of forms:

protected function _deconstructDate($value, $options)
    {
        ...

        $value = $value->timezone('Europe/Berlin');

But one would also need to fix the input convertion, otherwise it will always add +2 more...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions