javascript date range
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
function getDates(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
while (currentDate <= stopDate) {
dateArray.push(new Date (currentDate));
currentDate = currentDate.addDays(1);
}
return dateArray;
}
0
0
Array(to - from + 1)
.fill('') // .fill() is not IE compliant
.map((_, i) => from + i));
// (2000, 2003) => [2000,2001,2002,2003]
Thank you!
0
0
Are there any code examples left?
New code examples in category Javascript