J.W.
J.W.

Reputation: 1

google apps script convert string to object

I have a question about the date convert: in sheet, I have a date '05/11/2018', I need to get next date 06/11/2018.

var end=Utilities.formatDate(new Date(coach_date.getTime()+1*3600000*24), 'GMT', 'dd/MM/yyyy');
var start = new Date();
var events = calendar.getEvents(start,end);
it shows the 'end' is string, not object. it has to be getEvents(object,object)

so I used end = new Date(end); it got '11/06/2018', change month from Nov to June.

How could I fix it, then use it on getevents() feature. Thanks a lot.

Upvotes: 0

Views: 980

Answers (1)

TheMaster
TheMaster

Reputation: 50443

Utilities.formatDate() converts the date object into a string. So, use

var end = coach_date.setDate(coach_date.getDate()+1);

Upvotes: 1

Related Questions