var date = new Date(); // Now
date.setDate(date.getDate() + 30); // Set now + 30 days as the new date
console.log(date);
Answer from Lennholm on Stack Overflow
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › date-add-days
JavaScript Add Days to Date - Mastering JS
const date = new Date('2022-06-01'); // June 1, 2022 UTC time date.setDate(date.getDate() + 30); // Add 30 days date; // July 1, 2022 UTC time
🌐
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 the setDate() method which automatically handles month boundaries, year transitions, and leap years. This native JavaScript method eliminates edge case bugs that plague manual date arithmetic.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-add-days-to-date-in-javascript
How to Add Days to Date in JavaScript? - GeeksforGeeks
July 23, 2025 - To add a specific number of days to a date, we first convert the days into milliseconds and then add them to the current date represented in milliseconds. This approach enables precise date manipulation in JavaScript.
🌐
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
Top answer
1 of 4
43

Updated answer (2018)

One way to add 30 days to a date string is to parse it to a Date, add 30 days, then format it back to a string.

Date strings should be parsed manually, either with a bespoke function or a library. Either way, you need to know the format to know if it's been parsed correctly, e.g.

// Given a string in m/d/y format, return a Date
function parseMDY(s) {
  var b = s.split(/\D/);
  return new Date(b[2], b[0]-1, b[1]);
}

// Given a Date, return a string in m/d/y format
function formatMDY(d) {
  function z(n){return (n<10?'0':'')+n}
  if (isNaN(+d)) return d.toString();
  return z(d.getMonth()+1) + '/' + z(d.getDate()) + '/' + d.getFullYear();
}

// Given a string in m/d/y format, return a string in the same format with n days added
function addDays(s, days) {
  var d = parseMDY(s);
  d.setDate(d.getDate() + Number(days));
  return formatMDY(d);
}

[['6/30/2018', 30],
 ['1/30/2018', 30], // Goes from 30 Jan to 1 Mar
 ['12/31/2019', 30]].forEach(a => {
  console.log(`{addDays(...a)}`);
});

If the "30 days" criterion is interpreted as adding a month, that is a bit trickier. Adding 1 month to 31 January will give 31 February, which resolves to 2 or 3 March depending on whether February for that year has 28 or 29 days. One algorithm to resolve that is to see if the month has gone too far and set the date to the last day of the previous month, so 2018-01-31 plus one month gives 2018-02-28.

The same algorithm works for subtracting months, e.g.

/**
 * @param {Date} date - date to add months to
 * @param {number} months - months to add
 * @returns {Date}
*/
function addMonths(date, months) {

  // Deal with invalid Date
  if (isNaN(+date)) return;
  
  months = parseInt(months);

  // Deal with months not being a number
  if (isNaN(months)) return;

  // Store date's current month
  var m = date.getMonth();
  date.setMonth(date.getMonth() + months);
  
  // Check new month, if rolled over an extra month, 
  // go back to last day of previous month
  if (date.getMonth() != (m + 12 + months)%12) {
    date.setDate(0);
  }
  
  // date is modified in place, but return for convenience
  return date;
}

// Helper to format the date as D-MMM-YYYY
// using browser default language
function formatDMMMY(date) {
  var month = date.toLocaleString(undefined,{month:'short'});
  return date.getDate() + '-' + month + '-' + date.getFullYear();
}

// Some tests
[[new Date(2018,0,31),  1],
 [new Date(2017,11,31), 2],
 [new Date(2018,2,31), -1],
 [new Date(2018,6,31), -1],
 [new Date(2018,6,31), -17]].forEach(a => {
   let f = formatDMMMY;
   console.log(`${f(a[0])} plus ${a[1]} months: ${f(addMonths(...a))}`); 
});

Of course a library can help with the above, the algorithms are the same.

Original answer (very much out of date now)

Simply add 30 days to todays date:

var now = new Date();
now.setDate(now.getDate() + 30);

However, is that what you really want to do? Or do you want to get today plus one month?

You can convert a d/m/y date to a date object using:

var dString = '9/5/2011';
var dParts = dString.split('/');
var in30Days = new Date(dParts[2] + '/' +
                        dParts[1] + '/' +
                        (+dParts[0] + 30)
               );

For US date format, swap parts 0 and 1:

var in30Days = new Date(dParts[2] + '/' +
                        dParts[0] + '/' +
                        (+dParts[1] + 30)
               );

But it is better to get the date into an ISO8601 format before giving it to the function, you really shouldn't be mixing date parsing and arithmetic in the same function. A comprehensive date parsing function is complex (not excessively but they are tediously long and need lots of testing), arithmetic is quite simple once you have a date object.

2 of 4
16

A simple way to get it done is to send the timestamp value in the Date constructor. To calculate 30 days measured in timestamp:

30 * 24 * 60 * 60 * 1000

Then, you need the current timestamp:

Date.now()

Finally, sum both values and send the result as a param in the constructor:

var nowPlus30Days = new Date(Date.now() + (30 * 24 * 60 * 60 * 1000));

🌐
Medium
medium.com › @divyankojha16 › get-next-30th-day-timestamp-in-javascript-d5e29c3f0300
GET next 30th day timestamp in Javascript | by Divyank Ojha | Medium
February 22, 2023 - const next30DaysDate = new Date(next30Days); const formattedDate = next30DaysDate.toLocaleDateString('en-US'); console.log(formattedDate); // e.g. "3/22/2023" In the above code, we create a new Date object with the timestamp for 30 days from now.
Find elsewhere
🌐
Acrobatusers
answers.acrobatusers.com › How-add-30-days-date-q86922.aspx
How to add 30 days onto date? (JavaScript)
... Have you looked at Thom Parker's Working with date and time in Acrobat JavaScript tutorial in the Learning Center? Instead of using the computed number of milliseconds, one can use the getDate method to get the date of the month and then add the number of days to that date.
🌐
The Valley of Code
thevalleyofcode.com › how-to-add-days-date-javascript
How to add days to a date in JavaScript
Today I have the solution to this problem: you have a Date object in JavaScript, and you want to add some days to it. ... Suppose we want to get the date that’s “30 days from now”.
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 $in = $(this);
    var $out = $('<td/>').insertAfter($in).addClass("answer");
    var $outFail = $('<td/>').insertAfter($out);
    var $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>

🌐
TutorialsPoint
tutorialspoint.com › how-to-add-number-of-days-to-javascript-date
How to add number of days to JavaScript Date?
The value returned by the getTime() ... first, we get the current time by using the Date.getTime( ) method and then add the millisecond value of the number of days to be added to it and pass the added value to the Date Object....
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-add-days-to-current-date-in-javascript.php
How to Add Days to Current Date in JavaScript
Similarly, you can also add number of days to a particular date in JavaScript. Try this code » · // 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); Here are some more FAQ related to this topic: How to format a JavaScript date ·
🌐
MSR
rajamsr.com › home › how to add days to date in javascript with 3 examples
How to Add Days to Date in JavaScript With 3 Examples | MSR - Web Dev Simplified
January 18, 2024 - With this approach, you can add one day to a date by changing the numberOfDaysToAdd variable value to 1. To add 30 days to the date, you can change the numberOfDaysToAdd value to 30.
🌐
Code with Hugo
codewithhugo.com › add-date-days-js
Add days to a Date in vanilla JavaScript · Code with Hugo
May 1, 2020 - const d = new Date('2019-04-14'); const monthRollsOver = addDays(myDate, 31); console.log(monthsRollOver) // 2019-05-15 · Find the live examples at: observablehq.com/@hugodf/add-days-to-a-javascript-date