I'm trying to combine date and time into one element in google app script array. This is for converting data from google sheet into google calendar.
I've 4 elements in my array; title, date, start time, end time. Each of them were retrieved by .getValues
from google sheet.
title1 | Aug 08,2019 | 7:30 | 8:25
title2 | Aug 10,2019 | 8:30 | 9:25
I want to grab date and time from google sheet then createEvent in calendarApp.
//so with .getValues() in cArr variable from the table above I tried this code:
for (var i = 0; i <= cArr.length; i++){
CalendarApp.getCalendarById("myCalendarID").createEvent(cArr[i][0],cArr[i][2],cArr[i][2]);
};
The script were successfully run without error. But the event didn't appear in my calendar. I assume the events ever create in 1899 since it didn't specified the date in element [2] and [3].
Through some research, my best guess is to modify the array elements to be in 'MMM dd/yyyy, HH:mm' for both element [1] and [3]. But I just can't find a solution to do it. In the end, I want the result array like
[
["title1","Aug 08/2019, 7:30","Aug 08/2019, 8:25"],
["title2","Aug 10/2019, 8:30","Aug 10/2019, 9:25"]
]
Before I use this new array in .createEvent
.