Skip to content

DateTime for America/City is not store correctly in UTC #5588

@ronnytorresmtz

Description

@ronnytorresmtz
  • Laravel Version: 9.52.7
  • Nova Version: 3.32.0
  • PHP Version: 8.1.19
  • Database Driver & Version: mysql Ver 8.0.30
  • Operating System and Version: Windows 11
  • Browser type and version: Chrome 114.0.5735.91

Description:

In Nova, I'm using a DateTime field with my timezone set to America/Mexico_City. However, I noticed that when this field is saved, it's stored in UTC format, but the hour value is not correct.

For example, when saving an event with a time of 8:00, I would expect it to be saved as 14:00 in UTC format in the database, considering that the offset for this timezone is 6 hours and it doesn't observe Daylight Saving Time. However, I see that it's being saved with the hour value of 13:00. Consequently, when retrieving the event and transform the UTC date to the Timezone (America/Mexico_City), it displays 7:00 instead of the expected 8:00, as you can see in the attached video.

Nova Form Detail displays correctly but if you take the value store (13:00) and you transform with php to the timezone it gets the time incorrently as I mentioned above because should be store as 14:00.

I add a repository with an laravel nova example-app with a field call "Start" as a Datetime in the Users Table, just for testing if you need.

https://github.com/ronnytorresmtz/example-app

You can see in the image what I said about the 8:00 in utc is 14:00 :
UTC vs Amercia_Mexico_City

Detailed steps to reproduce the issue on a fresh Nova installation:

I add a repository with an laravel nova example-app with a field call "Start" as a Datetime in the Users Table, just for testing if you need.

So you can input in the start field any date with time 8:00 (Amercia/Mexico_City) and you will see in te field UTC Date 13:00 and it is wrong should be 14:00 as you see in the above image.

https://github.com/ronnytorresmtz/example-app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions