I have a calendar component on my page, it calls in events from a third party.
Option 1:
I set the Calendar components Timezone
to local
I click a CHECK AVAILABILITY button to fetch all the events.
The events all display correctly as 09:30.
I set a dmx-on:eventclick="var_event_selected.setValue($event.event.start()"
This populated a variable I can use later on, however when calling this variable with var_event_selected.value
it returns the date and time but 2 hours less than selected.
2021-03-06T07:30:00.000Z
If I now decide I would like to just format the date, just using the date formatter which should not alter the date itself, I use var_event_selected.value.formatDate('yyyy-MM-dd HH:mm:ss')
and that outputs as 2021-03-06 09:30:00
So by just using the formatter it adjusts the date to be as selected.
Option 2
I set the Calendar components Timezone
to UTC
(Which is actually what I want)
I do the same steps as above, the events still show as 09:30, however the standard output of
var_event_selected.value
now correctly returns 2021-03-06T09:30.000Z
The problem comes in again when i want to format this, suddenly it turns to local again and a simple var_event_selected.value.formatDate('yyyy-MM-dd HH:mm:ss')
outputs 2021-03-06 11:30:00
EDIT: The one strange thing I can do to fix the issue is to use this
var_event_selected.value.replace('Z','').formatDate('yyyy-MM-dd HH:mm:ss')
and now it goes back to 2021-03-06 09:30:00
as I wanted.
Last updated: