sanity: Dates in Studio are being displayed in "local" time, causing data to look wrong to editors in different timezones.

Describe the bug

I’m using both the datetime and richDate schema types to set dates for “show” documents, which will be used to list out upcoming shows. If I create my event in, say, Denver and set a date to 2020-06-21 20:30 and then open my studio up in, say, Los Angeles, the date being displayed in my fields and previews are showing the above time localized. This will appear as an error to someone looking at the studio from a different timezone than the one the document was created/updated from, which may result in them changing it again, which would in turn affect the original, intended date, and on and on you could go…

Expected behavior

The date should remain the same as what it was set at for all editors, as well as what’s returned in queries.

Screenshots

Here are two instances of Google Chrome running my studio, the one on the left is mimicking “Los Angeles” (PDT) timezone, while the one on the right is my default Chrome instance, where I’m in “Denver” (MDT) timezone

image

Notice the displayed data is different by an hour? I had set the date in my default timezone, then pretended to fire it up in Los Angeles and the time is off by an hour, because it’s being converted from the time it was set at to the current local time.

Technical Details

Which versions of Sanity are you using?

@sanity/cli               1.149.2 (latest: 1.149.16)
@sanity/base             1.149.16 (up to date)
@sanity/components       1.149.16 (up to date)
@sanity/core             1.149.17 (up to date)
@sanity/dashboard        1.149.16 (up to date)
@sanity/default-layout   1.149.16 (up to date)
@sanity/default-login    1.149.16 (up to date)
@sanity/desk-tool        1.149.16 (up to date)
@sanity/rich-date-input  1.149.16 (up to date)
@sanity/vision           1.149.16 (up to date)

What operating system are you using? Mac OS Catalina Version 10.15.4 (19E266)

Which versions of Node.js / npm are you running?

6.14.5
v12.13.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Any update on this. We are struggling with this issue currently.

@vicbergquist awesome! I’ve been thinking about this more, and wondering if a more explicit timezone setting should be added to date/time fields. That way you can use the set timezone to ensure the rendered value is the same no matter where the studio is being viewed from?

For now, I’ve stopped using the datetime and richdate fields, opting instead for the date field + a generic string field for entering the time. Luckily, my implementation doesn’t require granular time comparisons (just dates), but I imagine others won’t be so lucky!

Looking forward to seeing the solution for this 😎

I’m working on an ‘Event’ document in Sanity where the editors will be able to specify the start and end times of events. Having control over which timezone is displayed is essential when creating events that can happen in any given timezone.

Thank you for reporting! We agree that this can be confusing and we have added it to our internal tracker! 👍

Also struggling with this end of 2022 with editors using the studio from different timezones. Airtable has a good solution to this problem if you want to see an example.

I am facing up the same issue 🙏

Any new update on this? I would like to input the date as UTC

Do we have solution for this date and time issue ?

Another ping for this. Also facing the same problem. Didn’t want to resort to forking the code just to try to patch a fix for it