Increase a Date in JavaScript by One Week

When building tools that work with dates, you may want to provide a button that acts as a shortcut to increase a date by one week. Internally, your application still works with actual dates and you may want to calculate the date in one week.

This tutorial shows you how to increase a date in JavaScript by one week.

Node.js Series Overview

Increase a Date in JavaScript by One Week

JavaScript’s global Date class provides dozens of methods to manipulate a date instance. Increasing a date instance by one week is basically a calculation of adding seven days to today:

const nextWeek = new Date()

// add 7 days to the current date
nextWeek.setDate(new Date().getDate() + 7)

console.log(nextWeek)  
// 2020-01-03T11:08:14.918Z

Starting from today, you may retrieve the current days in the month using the .getDate() method. You can then go ahead and add 7 more days to increase the days by one week.

Increase the days of a JavaScript date instance using the .setDate() method. The benefit provided by JavaScript: it automatically switches the month in case you’re exceeding the days in a month.

You may also be interested in the related tutorial showing how to retrieve tomorrow’s date in JavaScript.

That’s it! Enjoy dates and make it rock!


Mentioned Resources

Explore the Library

Find interesting tutorials and solutions for your problems.