Sometimes, we want to add 1 month from now to current date in moment.js and JavaScript.
In this article, we’ll look at how to add 1 month from now to current date in moment.js and JavaScript.
How to add 1 month from now to current date in moment.js and JavaScript?
To add 1 month from now to current date in moment.js and JavaScript, we can use the add
method.
For instance, we write
const startDate = "20-03-2022";
const newDate = moment(startDate, "DD-MM-YYYY").add(5, "days");
to call moment
to parse startDate
into a moment object.
Then we call add
with 5 and 'days'
to return a new moment object with date 5 days after startDate
.
Conclusion
To add 1 month from now to current date in moment.js and JavaScript, we can use the add
method.