I have an application where I need the Datepicker widget to display a time stamp from a database in the time zone that an event took place in instead of the local timezone of the person using the application. I can use moment to convert a UTC time zone from the database to the desired displayed time zone, and the evaluated value shown for the default date is correct. However, the date that is actually displayed on the date picker is in my local time zone, rather than the time zone specified in the JS for the default date. Here is a screenshot of a working example:
@ryon Try the below snippet
{{moment('2022-12-01T12:00:00.000-00:00').utc().tz('US/Eastern').format()}}
@dancia
It looks like this gives the undesired result in the evaluated value now, as well. If I remove the .format() function from your snippet, the evaluated value shows the desired Eastern time zone as before but the actual displayed value in the date picker is still showing my local Mountain time zone.
This looks like an issue with the Datepicker widget. It shows the date correctly if you bind it in a Text widget, for example. Let me check this and get back to you.
Using the Date() function, it looks a lot better
{{new Date('2022-12-01T12:00:00.000-00:00').toLocaleString('en-US', { timeZone: 'US/Eastern' })}}
1 Like