javascript date range

Solutions on MaxInterview for javascript date range by the best coders in the world

showing results for - "javascript date range"
Yannis
22 Jan 2019
1Date.prototype.addDays = function(days) {
2    var date = new Date(this.valueOf());
3    date.setDate(date.getDate() + days);
4    return date;
5}
6
7function getDates(startDate, stopDate) {
8    var dateArray = new Array();
9    var currentDate = startDate;
10    while (currentDate <= stopDate) {
11        dateArray.push(new Date (currentDate));
12        currentDate = currentDate.addDays(1);
13    }
14    return dateArray;
15}
Aaliyah
29 Jan 2021
1Array(to - from + 1)
2          .fill('') // .fill() is not IE compliant
3          .map((_, i) => from + i));
4
5// (2000, 2003) => [2000,2001,2002,2003]