Reputation: 15
The getStartTime()
and getEndTime()
is only returning the date. How can I get the start and end time of the event?
var allEvents = calendar.getEvents(new Date('June 3, 2020'), new Date('August 6, 2020'));
var startDateTime = allEvents[j].getStartTime();
var endDateTime = allEvents[j].getEndTime();
Upvotes: 0
Views: 1642
Reputation: 27360
startDateTime
and endDateTime
are Date objects, meaning you can apply all the relevant methods.
var allEvents = calendar.getEvents(new Date('June 3, 2020'), new Date('August 6, 2020'));
var startDateTime = allEvents[j].getStartTime();
var startDateTime24 = startDateTime.getHours() + ":" + startDateTime.getMinutes()
var endDateTime = allEvents[j].getEndTime();
var endDateTime24 = endDateTime.getHours() + ":" + endDateTime.getMinutes()
Now startDateTime24
and endDateTime24
contain the time of the start and end of the event respectively in the 24-hour notation in the form hh:mm.
Note in the code I assume that calendar
holds a reference to an instance of CalendarApp
.
Upvotes: 1