You can create one using Date.prototype.setDate():

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

var date = new Date();

console.log(date.addDays(5));

This takes care of automatically incrementing the month if necessary, as noted here. For example:

8/31 + 1 day will become 9/1.

The problem with using setDate directly is that it's a mutator and that sort of thing is best avoided. ECMA saw fit to treat Date as a mutable class rather than an immutable structure.

Answer from AnthonyWJones on Stack Overflow
Top answer
1 of 16
1850

You can create one using Date.prototype.setDate():

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

var date = new Date();

console.log(date.addDays(5));

This takes care of automatically incrementing the month if necessary, as noted here. For example:

8/31 + 1 day will become 9/1.

The problem with using setDate directly is that it's a mutator and that sort of thing is best avoided. ECMA saw fit to treat Date as a mutable class rather than an immutable structure.

2 of 16
1171

Correct Answer:

function addDays(date, days) {
  var result = new Date(date);
  result.setDate(result.getDate() + days);
  return result;
}

Incorrect Answer:

This answer sometimes provides the correct result but very often returns the wrong year and month. The only time this answer works is when the date that you are adding days to happens to have the current year and month.

// Don't do it this way!
function addDaysWRONG(date, days) {
  var result = new Date(); // not instatiated with date!!! DANGER
  result.setDate(date.getDate() + days);
  return result;
}

Proof / Example

Check this JsFiddle

// Correct
function addDays(date, days) {
    var result = new Date(date);
    result.setDate(result.getDate() + days);
    return result;
}

// Bad Year/Month
function addDaysWRONG(date, days) {
    var result = new Date();
    result.setDate(date.getDate() + days);
    return result;
}

// Bad during DST
function addDaysDstFail(date, days) {
    var dayms = (days * 24 * 60 * 60 * 1000);
    return new Date(date.getTime() + dayms);    
}

// TEST
function formatDate(date) {
    return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
}

$('tbody tr td:first-child').each(function () {
    var (this);
    var ('<td/>').insertAfter($in).addClass("answer");
    var $outFail = $('<td/>').insertAfter(outDstFail = $('<td/>').insertAfter($outFail);
    var date = new Date($in.text());
    var correctDate = formatDate(addDays(date, 1));
    var failDate = formatDate(addDaysWRONG(date, 1));
    var failDstDate = formatDate(addDaysDstFail(date, 1));

    $out.text(correctDate);
    $outFail.text(failDate);
    $outDstFail.text(failDstDate);
    $outFail.addClass(correctDate == failDate ? "right" : "wrong");
    $outDstFail.addClass(correctDate == failDstDate ? "right" : "wrong");
});
body {
    font-size: 14px;
}

table {
    border-collapse:collapse;
}
table, td, th {
    border:1px solid black;
}
td {
    padding: 2px;
}

.wrong {
    color: red;
}
.right {
    color: green;
}
.answer {
    font-weight: bold;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
    <tbody>
        <tr>
            <th colspan="4">DST Dates</th>
        </tr>
        <tr>
            <th>Input</th>
            <th>+1 Day</th>
            <th>+1 Day Fail</th>
            <th>+1 Day DST Fail</th>
        </tr>
        <tr><td>03/10/2013</td></tr>
        <tr><td>11/03/2013</td></tr>
        <tr><td>03/09/2014</td></tr>
        <tr><td>11/02/2014</td></tr>
        <tr><td>03/08/2015</td></tr>
        <tr><td>11/01/2015</td></tr>
        <tr>
            <th colspan="4">2013</th>
        </tr>
        <tr>
            <th>Input</th>
            <th>+1 Day</th>
            <th>+1 Day Fail</th>
            <th>+1 Day DST Fail</th>
        </tr>
        <tr><td>01/01/2013</td></tr>
        <tr><td>02/01/2013</td></tr>
        <tr><td>03/01/2013</td></tr>
        <tr><td>04/01/2013</td></tr>
        <tr><td>05/01/2013</td></tr>
        <tr><td>06/01/2013</td></tr>
        <tr><td>07/01/2013</td></tr>
        <tr><td>08/01/2013</td></tr>
        <tr><td>09/01/2013</td></tr>
        <tr><td>10/01/2013</td></tr>
        <tr><td>11/01/2013</td></tr>
        <tr><td>12/01/2013</td></tr>
        <tr>
            <th colspan="4">2014</th>
        </tr>
        <tr>
            <th>Input</th>
            <th>+1 Day</th>
            <th>+1 Day Fail</th>
            <th>+1 Day DST Fail</th>
        </tr>
        <tr><td>01/01/2014</td></tr>
        <tr><td>02/01/2014</td></tr>
        <tr><td>03/01/2014</td></tr>
        <tr><td>04/01/2014</td></tr>
        <tr><td>05/01/2014</td></tr>
        <tr><td>06/01/2014</td></tr>
        <tr><td>07/01/2014</td></tr>
        <tr><td>08/01/2014</td></tr>
        <tr><td>09/01/2014</td></tr>
        <tr><td>10/01/2014</td></tr>
        <tr><td>11/01/2014</td></tr>
        <tr><td>12/01/2014</td></tr>
        <tr>
            <th colspan="4">2015</th>
        </tr>
        <tr>
            <th>Input</th>
            <th>+1 Day</th>
            <th>+1 Day Fail</th>
            <th>+1 Day DST Fail</th>
        </tr>
        <tr><td>01/01/2015</td></tr>
        <tr><td>02/01/2015</td></tr>
        <tr><td>03/01/2015</td></tr>
        <tr><td>04/01/2015</td></tr>
        <tr><td>05/01/2015</td></tr>
        <tr><td>06/01/2015</td></tr>
        <tr><td>07/01/2015</td></tr>
        <tr><td>08/01/2015</td></tr>
        <tr><td>09/01/2015</td></tr>
        <tr><td>10/01/2015</td></tr>
        <tr><td>11/01/2015</td></tr>
        <tr><td>12/01/2015</td></tr>
    </tbody>
</table>

🌐
W3Schools
w3schools.com › js › tryit.asp
JavaScript Dates
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
CoreUI
coreui.io › answers › how-to-add-days-to-date-in-javascript
How to add days to date in JavaScript · CoreUI
September 30, 2025 - The most reliable approach is using ... eliminates edge case bugs that plague manual date arithmetic. Use setDate() with getDate() to safely add days to any date....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
The following examples show how to determine the elapsed time between two JavaScript dates in milliseconds. Due to the differing lengths of days (due to daylight saving changeover), months, and years, expressing elapsed time in units greater than hours, minutes, and seconds requires addressing a ...
🌐
Envato Tuts+
code.tutsplus.com › home › javascript
How to Add or Subtract Days (And More) From Dates in Vanilla JavaScript | Envato Tuts+
June 8, 2023 - This tutorial will teach you how to add or subtract years, months, days, hours, minutes, or seconds from a date in vanilla JavaScript. No libraries required!
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › date-add-days
JavaScript Add Days to Date - Mastering JS
June 21, 2023 - JavaScript Dates have a setDate() function that sets the current date of the month. This function handles rolling over months, so setDate(32) will increment the date's month and set the correct date. For example, here's how you can add 30 days ...
Find elsewhere
🌐
Qualtrics Community
community.qualtrics.com › custom-code-12 › modifying-javascript-code-to-add-days-to-date-entered-17416
Modifying Javascript Code to Add Days to Date Entered | Experience Community
November 15, 2021 - Then, on the Text Entry question that collects the date, the following can be added to the OnReady section of the question's JavaScript: var qid = this.questionId; jQuery("#"+qid+" .InputText:eq(0)").on("change", function() { var theDate = new Date(jQuery("#"+qid+" .InputText:eq(0)").val()); var futureDateRaw5 = new Date(theDate); futureDateRaw5.setDate(futureDateRaw5.getDate()+5); var futureDateRaw10 = new Date(theDate); futureDateRaw10.setDate(futureDateRaw10.getDate()+10); console.log(futureDateRaw5); console.log(futureDateRaw10); var futureDate5 = (futureDateRaw5.getMonth() + 1) + '/' + fu
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-add-days-to-date-in-javascript
How to Add Days to Date in JavaScript? - GeeksforGeeks
July 23, 2025 - The setDate() method allows you to modify the day of the month for a Date object. To use this method, you start by creating a Date object that represents the current date. You can then add a specific number of days to this date and assign the ...
🌐
Medium
medium.com › @gaelgthomas › add-one-day-to-date-in-javascript-6b7d98b0edce
Add One Day to Date in JavaScript | by Gaël Thomas | Medium
December 21, 2022 - The best way to add 1 day to a JavaScript date is by using the Date object. On an existing Date, you can use the getDate function to get the day (between 1 and 31), add 1 to this number, then use setDate to update the date.
🌐
Geshan
geshan.com.np › blog › 2022 › 07 › javascript-add-days-to-date
How to add days to a date in JavaScript (with code examples)
July 26, 2022 - Still, like other parts of the language the date-related functions also have their own quirks like getDay returns 0-6 for Sunday - Saturday. In the next section, you will learn how to add days to a date in JavaScript using the setDate method.
🌐
Day.js
day.js.org › docs › en › manipulate › add
Add · Day.js
result = dayjs().add(dayjs.duration({'days' : 1}))
🌐
Full Stack Express
fullstackexpress.io › c › how-to-add-days-to-a-date-object-in-javascript
How to Add Days to a Date Object in JavaScript | Full Stack Express
Calling getDate() on our new date object gets us the day of the month according to local time. We can then add the number of days to this value.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-add-days-to-current-date-in-javascript.php
How to Add Days to Current Date in JavaScript
// Specific date var date = new Date('August 21, 2021 16:45:30'); // Add ten days to specified date date.setDate(date.getDate() + 10); console.log(date);
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
July 10, 2025 - new Date() new Date(value) new Date(dateString) new Date(dateObject) new Date(year, monthIndex) new Date(year, monthIndex, day) new Date(year, monthIndex, day, hours) new Date(year, monthIndex, day, hours, minutes) new Date(year, monthIndex, day, hours, minutes, seconds) new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds) Date()
🌐
Squash
squash.io › how-to-add-days-to-date-in-javascript
How To Add Days To a Date In Javascript
August 28, 2023 - Another approach to add days to a date in JavaScript is by using the getTime and setTime methods of the Date object. This approach allows for more flexible date manipulation and avoids the limitations mentioned in the previous approach.
Top answer
1 of 13
481

To add one day to a date object:

var date = new Date();

// add a day
date.setDate(date.getDate() + 1);
2 of 13
90

In my humble opinion the best way is to just add a full day in milliseconds, depending on how you factor your code it can mess up if you are on the last day of the month.

For example Feb 28 or march 31.

Here is an example of how I would do it:

var current = new Date(); //'Mar 11 2015' current.getTime() = 1426060964567
var followingDay = new Date(current.getTime() + 86400000); // + 1 day in ms
followingDay.toLocaleDateString();

Imho this insures accuracy

Here is another example. I do not like that. It can work for you but not as clean as example above.

var today = new Date('12/31/2015');
var tomorrow = new Date(today);
tomorrow.setDate(today.getDate()+1);
tomorrow.toLocaleDateString();

Imho this === 'POOP'

So some of you have had gripes about my millisecond approach because of day light savings time. So I'm going to bash this out. First, Some countries and states do not have Day light savings time. Second Adding exactly 24 hours is a full day. If the date number does not change once a year but then gets fixed 6 months later I don't see a problem there. But for the purpose of being definite and having to deal with allot the evil Date() I have thought this through and now thoroughly hate Date. So this is my new Approach.

var dd = new Date(); // or any date and time you care about 
var dateArray =  dd.toISOString().split('T')[0].split('-').concat( dd.toISOString().split('T')[1].split(':') );
// ["2016", "07", "04", "00", "17", "58.849Z"] at Z 

Now for the fun part!

var date = { 
    day: dateArray[2],
    month: dateArray[1],
    year: dateArray[0],
    hour: dateArray[3],
    minutes: dateArray[4],
    seconds:dateArray[5].split('.')[0],
    milliseconds: dateArray[5].split('.')[1].replace('Z','')
}

Now we have our Official Valid international Date Object clearly written out at Zulu meridian. Now to change the date

dd.setDate(dd.getDate()+1); // this gives you one full calendar date forward
tomorrow.setDate(dd.getTime() + 86400000);// this gives your 24 hours into the future. do what you want with it.
🌐
LambdaTest Community
community.lambdatest.com › general discussions
How to add days to a date in JavaScript? Is there a built-in function like .NET's AddDay() to add days to the current date using JavaScript? - LambdaTest Community
April 21, 2024 - How to add days to Date using JavaScript? How to add days to current Date using JavaScript? Does JavaScript have a built-in function like .NET’s AddDay()?
🌐
Futurestud.io
futurestud.io › tutorials › add-days-to-a-date-in-javascript-or-node-js
Add Days to a Date in JavaScript or Node.js
July 7, 2022 - JavaScript has a handful of methods to set a unit, like days, months, or years. The method allowing you to customize the days of a date is setDate. Here’s a sample function adding a given number of days to an optional date.
🌐
Devcurry
devcurry.com › 2011 › 01 › add-days-to-date-in-javascript.html
Add Days to Date in JavaScript
JavaScript provides the Date object for manipulating date and time. Amongst the various methods of the Date object, the one will be focusing in this post are the setDate(value) and getDate() which sets and gets the day of the month respectively.