I am trying to create calendar events from google sheets where start and end time are given in two sells and the correct time zone is third.
As calendarID.createEvent(title, startDate, endDate)
wants startDate
and endDate
to be Date() objects I cannot set the right Time zone for the events.
Start Time | End Time | Time Zone |
---|---|---|
01/01/2022 14:00 | 01/01/2022 15:00 | Europe/Prague |
01/01/2022 14:00 | 01/01/2022 15:00 | Asia/Dubai |
If I have these for example I want these events to be created in my calendar with the correct timezone so I can see them aligned to my calendar timezone which is for example Europe/Sofia.
I have tried :
var startDate = Utilities.formatDate(new Date(entry[0]), entry[2].valueOf(), 'MMMM dd, yyyy HH:mm Z'); var endDate = Utilities.formatDate(new Date(entry[1]), entry[2].valueOf(), 'MMMM dd, yyyy HH:mm Z');
but that creates strings and the createEvent()
function gives error.
I also tried many different formats and conversions but in the end when when I try to make Date()
variables they are always in -0500 timezone and so not correctly created in the calendar.
Any help will be much appreciated. Thank you.