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
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-adding-days-in-milliseconds-to-date-object
JavaScript Adding days in milliseconds to Date object - GeeksforGeeks
July 11, 2025 - JavaScript setMilliseconds() Method: This method sets the milliseconds of a date object. ... millisec: This parameter is required. It specifies the number of milliseconds to be added/subtracted, midnight January 1, 1970
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-add-or-remove-days-from-javascript-dates-c99003d7600e
How to Add or Remove Days from JavaScript Dates | by Oskar Petr | JavaScript in Plain English
June 15, 2022 - We can get the value with a get method to add/subtract any number of date types and set the new value to the date’s date type. This can be more usable because we do not need the initialized values at the beginning and we can modify it later. ... New JavaScript and Web Development content every day.
🌐
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!
🌐
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.
🌐
Camelback Resort
camelbackresort.com › ski-ride-season-passes
Ski Season Passes | Camelback Resort Poconos PA
2 weeks ago - The Unlimited Pass includes every perk, every day—no blackout dates, no limitations. Perfect for riders who want maximum freedom across the 26/27 season. Add a Children’s Unlimited Pass (ages 6–9) for just $79 to keep the whole family riding together.*
Find elsewhere
🌐
DEV Community
dev.to › luispa › adding-days-to-a-date-using-vanilla-js-16a2
Adding days to a date using Vanilla JS - DEV Community
March 24, 2020 - function addDays(date, days) { const copy = new Date(Number(date)) copy.setDate(date.getDate() + days) return copy } const date = new Date(); const newDate = addDays(date, 10);
🌐
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 ...
🌐
devstudioonlinecom
devstudioonline.com › article › add-and-subtract-day-month-year-in-javascript-date
Add and Subtract day, month, year in Javascript Date
February 28, 2020 - We have explained different addition and Subtraction with the example below: Add or Subtract Days: const date = new Date(); const additionOfDays = 10; date.setDate(date.getDate() + additionOfDays); // For subtract use minus (-) console.log('New ...
🌐
GitHub
gist.github.com › 8328881
Add days method for Date object.
Clone this repository at &lt;script src=&quot;https://gist.github.com/7LayersDesign/8328881.js&quot;&gt;&lt;/script&gt; Save 7LayersDesign/8328881 to your computer and use it in GitHub Desktop. ... Add days method for Date object.
🌐
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....
🌐
Jay Peak
jaypeakresort.com
Jay Peak | Four Season Resort | Vermont
Packages start at $204 per night for two adults and include 2-day concert access. Choose lodging only or bundle in waterpark access and turn your hours off the hill into something just as loud. ... Available across select dates.
🌐
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.
🌐
Epoch Converter
epochconverter.com
Epoch Converter - Unix Timestamp Converter
Also see our dynamic list of dates (1 day ago, next week, etc.) Press c to clear all forms.
🌐
Day.js
day.js.org › docs › en › manipulate › add
Add · Day.js
result = dayjs().add(dayjs.duration({'days' : 1}))
🌐
TutorialsPoint
tutorialspoint.com › increment-a-given-date-in-javascript
Increment a given date in JavaScript
March 9, 2023 - In this article, we are going to discuss how to increment a given date using JavaScript. First, we will analyse and understand what is meant by this. Given a certain date x = "05-02-2023", we want to add y = 7 days to this date and print the resulting date which is "12-02-2023".
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
For example, new Date(99, 5, 24) is interpreted as June 24, 1999, not June 24, 99. See Interpretation of two-digit years for more information. When a segment overflows or underflows its expected range, it usually "carries over to" or "borrows from" the higher segment. For example, if the month is set to 12 (months are zero-based, so December is 11), it becomes the January of the next year. If the day of month is set to 0, it becomes the last day of the previous month.