Answers for "javascript date range"

0

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;
}
Posted by: Guest on April-25-2021
0

javascript date range

Array(to - from + 1)
          .fill('') // .fill() is not IE compliant
          .map((_, i) => from + i));

// (2000, 2003) => [2000,2001,2002,2003]
Posted by: Guest on May-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language