I'm trying to convert an array of days:
['1','2','3','4','5']
to an array of dates which are today +1 day , today +2 etc
I have:
interval_dates = []
var intervals = rows[index+1][0].split(',')
var now = new Date();
for (i in intervals){
// add a day
interval_dates.push(now.setDate(now.getDate() + intervals[i]));
}
Logger.log(interval_dates);
I'm seeing
[1.505998326018E12, 1.522500726018E12, 1.546869126018E12, 1.552654326018E12, 1.564750326018E12], ]
what am I doing wrong?
The intervals are string, you need to get the day of today and add the interval after converting it to a number using
+interval
, so it would benow.getDate() + +intervals[i]
, then callnew Date()
on the result, and of course change the loop fromi in intervals
to a number range: