I'm trying to console.log
all the dates between two dates.
Here is the code i have so far:
var dString = "18.04.2018";
var dParts = dString.split('.');
var in30Days = new Date(dParts[2] + '/' +
dParts[1] + '/' +
(+dParts[0] + 10)
);
var endDate = in30Days.getDate() + "." + (in30Days.getMonth()+1) + "." +in30Days.getFullYear();
console.log("Now:" + dString + " EndDate: " + endDate);
for (var d = dString; d <= endDate; d.setDate(d.getDate() + 1)) {
var loopDay = new Date(d);
console.log("Day:" + loopDay);
}
The end date is the start date plus 10 days.
Here is the console log output i receive:
Now:18.04.2018 EndDate: 28.4.2018
Day:Invalid Date
Why the date is invalid. Where is my mistake ?