Time Zone for CMS Date Fields

Question:
Is there any way to adjust the default behavior of Date fields displaying in the viewer’s current time zone so they display a specific local time zone only (Pacific Standard Time)?

Product:
Wix Studio and CMS Collection

What are you trying to achieve:
We have a CMS Collection for events that all occur in the Los Angeles area. We enter the date & time of the event in a ‘Date w/ Time’ field. I guess I didn’t realize that when we add this field to the individual event pages via dataset, by default they will display in the time zone of the viewer, since this is a bit tough to test. For local events, it just make more sense that the date & time displayed should be what it is where the event takes place.

But the trickier situation is that we use some Velo functions to display a button that allows the user to order something to be delivered to the event. But this needs to only display if the event is more than 48 hours in the future, so there is time to fulfill the order.

I’m using Date(now.toLocaleString("en-US", {timeZone: "America/Los_Angeles"})) on the Velo function to try to enforce that the current time of the viewer is adjusted for PST. But I believe the calculated time until the event is based upon the date & time queried from the Date field of the CMS collection, which I think is still in the viewer’s local time zone. So calculations may be off. Some viewer’s may be in Japan, so this could be WAY off.

Hi, @Kenny_H !!

Hello, or good evening! A Japanese person has arrived. I think date-related issues can be especially confusing. In particular, if you forget which country’s time zone the dates in the collection are based on, things can get quite complicated. Fortunately, I live in Japan, so I might be able to check if your code is working correctly. If you create a simple test page, I can view it and let you know how the dates are displayed! :open_mouth:

Also, when dealing with date-related confusion, storing the time in UTC (as a numeric value) in the collection can help avoid misunderstandings.

Hi, thanks for the response! I was able to figure out how to fudge my time zone by using the Sensors settings in Chrome Dev Tools Inspector. But thanks for offering to look!

Let me ask your opinion. If you were viewing local events that only took place in a particular city, and were not online events, would you expect the date & time for the event to be listed as the time zone of the event itself, or adjusted for what your local time would be? So for example, would seeing an event that actually takes place on a Monday morning in the Los Angeles be listed as the middle of the night Tuesday be more clear or more confusing?

And I believe, according to the notes on this page, that the dates may be stored in the collection database as UTC+0. That’s what I was trying to see if I could override somehow. Please correct me if I’m misunderstanding the default here.

THANKS!

Of course, displaying the event time in the local time zone of the event location is the most user-friendly approach. As long as you clearly state, “The time displayed is in the local time zone of the event location,” there shouldn’t be any major issues. Even if someone is unaware of time zone differences worldwide, such cases are extremely rare.

However, if you’re concerned, you could also display the viewer’s local time and include a note such as, “The time difference between your local time and the event location’s local time is ○○ hours.” :grin:

I’m not quite sure I understand, but does this mean you used Chrome Dev Tools Inspector to change your time zone, for example to ‘Japan,’ and then checked how the program behaves? :open_mouth:

Yeah, you can use the Sensors section in Chrome Dev Tools to adjust your time zone and geolocation.

So now still need to see if there’s any way to adjust the default behavior of what is stored in a Collection for the Date field when displaying.

1 Like