0 points

Add days to JavaScript Date


dashboard

Tue Jul 07 2020 12:33:19 GMT+0000 (UTC)

Posted by @nikhil3790 #javascript

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

var date = new Date();

alert(date.addDays(5));
content_copy Copy

https://stackoverflow.com/questions/563406/add-days-to-javascript-date