# How to add days to a date in JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Dec 2, 2020, updated Sep 10, 2022. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-date-add-days

> A quick article to learn how to add days to the JavaScript Date object.

To add days to a date in JavaScript:

1. Use the `getDate()` method to get the day of the month for the given date.
2. Use the `setDate()` method, passing it the result of calling `getDate()` plus the number of days you want to add.
3. The `setDate()` method will add the specified number of days to the `Date` object.

For example, to add one day to the current date, use the following code:

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

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

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

```javascript
const date = new Date();
date.setDate(date.getDate() + 1)

console.log(date)
```

To add seven days to a `Date` object, use the following code:

```javascript
const date = new Date();

// Add 7 Days
date.setDate(date.getDate() + 7)

console.log(date)
```

You could even add a new method to the `Date`'s [prototype](https://attacomsian.com/blog/objects-prototypes-classes-javascript#prototypes) and call it directly whenever you want to manipulate days like below:

```javascript
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
```
