javascript
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);
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?
Similar Posts
- Add a month to Date in Javascript
- Get month name from a date using javascript
- Get current year using Javascript Date getFullYear() method
- Get year from given date using Javascript
- Get the day name from given date in Javascript
- Set default date in Jquery UI datepicker
- Add class to an element in javascript