To add days to a date in JavaScript, you can use the setDate() and getDate() methods of the Date object. These methods are used to set and get the day of the month of the Date object.

The following example demonstrates how you can add a day to the new instance of JavaScript Date object:

const today = new Date();
const tomorrow = new Date();

// Add 1 Day
tomorrow.setDate(today.getDate() + 1);

To update the existing JavaScript Date object, you can do the following:

const date = new Date();
date.setDate(date.getDate() + 7);

You could even add a new method to the Date's prototype and call it directly whenever you want to manipulate days like below:

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

// Add 7 Days
const date = new Date('2020-12-02');

console.log(date.addDays(7));
// 2020-12-09T00:00:00.000Z

✌️ Like this article? Follow me on Twitter and LinkedIn. You can also subscribe to RSS Feed.