How to add days to a date in JavaScript

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:

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:

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


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

const date = new Date();

// Add 7 Days
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')

// 2020-12-09T00:00:00.000Z

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

You might also like...

Digital Ocean

The simplest cloud platform for developers & teams. Start with a $200 free credit.

Buy me a coffee ☕

If you enjoy reading my articles and want to help me out paying bills, please consider buying me a coffee ($5) or two ($10). I will be highly grateful to you ✌️

Enter the number of coffees below:

✨ Learn to build modern web applications using JavaScript and Spring Boot

I started this blog as a place to share everything I have learned in the last decade. I write about modern JavaScript, Node.js, Spring Boot, core Java, RESTful APIs, and all things web development.

The newsletter is sent every week and includes early access to clear, concise, and easy-to-follow tutorials, and other stuff I think you'd enjoy! No spam ever, unsubscribe at any time.