Search code snippets, questions, articles...

Add months to a date in Javascript

If you are using Date in Javascript and want to add months to the date then you can use the Javascript code examples explained in this post.
const my_date = new Date();
console.log(my_date);

// Add 3 months to today's date
new Date(my_date.setMonth(my_date.getMonth() + 3));

console.log(my_date);
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Live Demo of the above code

We are using the Date.setMonth() function to add some months to the date. In the above code example, we are adding 3 months to the current date using javascript.

Was this helpful?
0 Comments