Here two simple snippets useful to add (or subtract) months to a Date object:
 

function add_months(dt, n) 
{
    return new Date(dt.setMonth(dt.getMonth() + n));      
}

dt = new Date();
console.log(add_months(dt, 10).toString());  

You can also create it as prototype, if you prefer:

Date.prototype.add_months = function(w){

var date = this;
date.setMonth( date.getMonth()+10 );

return date;

};

var date = new Date();
console.log( date.add_months(10).toString() );
Advertisements