Add A Year To Today's Date

You can create a new date object with todays date using the following code:

var d = new Date();
    console.log(d);
// => Sun Oct 11 2015 14:46:51 GMT-0700 (PDT)

If you want to create a date a specific time, you can pass the new Date constructor arguments

 var d = new Date(2014);
    console.log(d)

// => Wed Dec 31 1969 16:00:02 GMT-0800 (PST)

If you want to take todays date and add a year, you can first create a date object, access the relevant properties, and then use them to create a new date object

var d = new Date();
    var year = d.getFullYear();
    var month = d.getMonth();
    var day = d.getDate();
    var c = new Date(year + 1, month, day);
    console.log(c);

// => Tue Oct 11 2016 00:00:00 GMT-0700 (PDT)

You can read more about the methods on the date object on MDN

Date Object


Use the Date.prototype.setFullYear method to set the year to what you want it to be.

For example:

var aYearFromNow = new Date();
aYearFromNow.setFullYear(aYearFromNow.getFullYear() + 1);

There really isn't another way to work with dates in JavaScript if these methods aren't present in the environment you are working with.


One liner as suggested here

How to determine one year from now in Javascript by JP DeVries

new Date(new Date().setFullYear(new Date().getFullYear() + 1))

Or you can get the number of years from somewhere in a variable:

const nr_years = 3;
new Date(new Date().setFullYear(new Date().getFullYear() + nr_years))