.createEvent() doesn't work properly
When I executed the following code, an event was created at the wrong date and time. I wanted to create an event on 2021/2/21 17:00 - 22:00, but the event was created on 2021/2/22 7:00 - 12:00.
Here are my GAS code and a screenshot of my Google Calendar.
function pracCalendar() {
const id = 'foo@gmail.com';
const calendar = CalendarApp.getCalendarById(id);
const title = 'Test Event';
const startTime = new Date('2021/2/21 17:00');
const endTime = new Date('2021/2/21 22:00');
const options = {
description: 'Test Description',
location: 'Test Location',
guests: 'bar@gmail.com',
sendInvites: true
}
calendar.createEvent(title, startTime, endTime, options);
}
Is this caused by timezone?
I'm not sure if it's related but just in case... I currently live in Japan. My Google Calendar's timezone is Asia/Tokyo.
Could anyone tell me how to solve the problem?
