neos-development-collection icon indicating copy to clipboard operation
neos-development-collection copied to clipboard

DateTime selected in property editor does not match formatted output

Open fschwaiger opened this issue 8 years ago • 11 comments

Description

The DateTime property probably has issues with time zones.

Steps to Reproduce

  1. Have a Node with the property definition
    'myTimestamp':
      type: DateTime
      ui:
        inspector:
          editorOptions:
            format: 'd.m.Y H:i'
    
  2. Select 2017-10-18 10:00 from the editor.
  3. Save and Publish

Expected behavior

  • The property editor field should show 18.10.2017 10:00
  • The output of {myTimestamp -> f:format.date(format: 'H:i')} should be 10:00

Actual behavior

  • The property editor field shows 18.10.2017 11:00
  • The output of {myTimestamp -> f:format.date(format: 'H:i')} is 15:00 (my current timezone is UTC-5)

Thoughts

  • I think the date is saved as UTC, hence the 5 hour time difference in template formatting.
  • However, if I edit the time in UTC-5, I expect the same output here.
  • The one hour difference in the editor field could be due to daylight savings?

Affected Versions

Neos: 3.0.x-dev (not tested on any other version) Flow: 4.0.x-dev (not tested on any other version)

fschwaiger avatar Jan 18 '17 23:01 fschwaiger

Seems to be a duplicate of #851 and might be fixed with #1209 - can you check that, @fschwaiger? Thanks!

kdambekalns avatar Jan 19 '17 07:01 kdambekalns

I checked my project files and can see the change #1209 is there, however I can reproduce the issue when the date entered is on / after March 12 (DST change in Canada).

fschwaiger avatar Jan 19 '17 14:01 fschwaiger

I can currently reproduce the problem too, in Neos 2.3 With and without the patch mentioned in #1209

In the nodedata table, the date is stored correctly as UTC, but in the backend there is a one hour difference.

sbruggmann avatar Feb 01 '17 22:02 sbruggmann

Ok, some steps back..

Given We have a NodeType with a property named "dateTime" which is of type: DateTime. The Server's and Client's Timezone is: Europe/Zurich

Scenario 1: The property "dateTime" has defaultValue: 'today midnight' defined. Now I create a new Document Node which contains this property and select/enter "01.04.2017 18:00". This results in the following outputs.. Inspector: 01.04.2017 19:00 Frontend: 01.04.2017 17:00 Database:

    "dateTime": {
        "date": "2017-04-01 17:00:00.000000",
        "timezone": "UTC",
        "dateFormat": "Y-m-d H:i:s.u"
    }

Scenario 2: The property has no defaultValue defined. Now I create a new Document Node which contains this property and select/enter "01.04.2017 18:00". This results in the following outputs.. Inspector: 01.04.2017 18:00 Frontend: 01.04.2017 17:00 Database:

    "dateTime": {
        "date": "2017-04-01 17:00:14.000000",
        "timezone": "UTC",
        "dateFormat": "Y-m-d H:i:s.u"
    }

I don't get it..

sbruggmann avatar Feb 02 '17 12:02 sbruggmann

We still have this issue when using a DateTime in the creation dialog.

  • Server uses UTC.
  • Client uses Europe/Berlin
  • Selected date is 2023-01-01 00:00:00 (for "hiddenbeforedatetime")
  • Saved date is 2023-01-01 00:00:00
  • Visible date in the sidebar is 2023-01-01 01:00:00

Benjamin-K avatar Jan 13 '23 09:01 Benjamin-K

@Benjamin-K We have a customer where content editors are located around the globe. So they had trouble interpreting the DateTimes they entered in the Neos backend. In our case we configured all dates to be saved as UTC and we use the package https://github.com/flownative/neos-extendedtimeeditor (thanks @kitsunet for implementation for us) to visualise the timezone in backendend. The editor can even change the timezone for each date.

Maybe this can help you as well depending on your setup.

DrillSergeant avatar Jan 13 '23 11:01 DrillSergeant

@DrillSergeant Thanks for the hint, will have a look at the package later.

But as we do not have our editors located arount the globe, the default DateTime Editor should also work as expected. This is the case when only having to deal with the sidebar. But as soon as one uses it in the creation dialog, this doesn't work as expected.

I will also test this later for other DateTime properties that are not stored in a separate db column.

Benjamin-K avatar Jan 13 '23 11:01 Benjamin-K

Plain Neos 8.2 still has an issue with this, DateTime node properties get saved with wrong values (not for all my nodes, though… 🤯).

kdambekalns avatar Mar 29 '23 13:03 kdambekalns

I run into this today with Neos 8.3.9 and can confirm that the DateTime editor timezone that is stored to the database is not consistent across property inspector and creation dialog.

  • Property inspector: the server/php timezone is used
  • Creation dialog: the client timezone in used

Quickfix: I'll remove showInCreationDialog: true for now :-)

jobee avatar Feb 16 '24 12:02 jobee

@jobee You can also simply put the updated handler code in a new class in your project and configure Neos to use it…

  options:
    nodeCreationHandlers:
      creationDialogProperties:
        nodeCreationHandler: 'AcmeCom\Site\CreationDialogPropertiesCreationHandler'

kdambekalns avatar Feb 16 '24 16:02 kdambekalns

Is this sth that should be addressed in the issues of the Neos UI packages?

Benjamin-K avatar Feb 16 '24 20:02 Benjamin-K