Sometimes, we want to use moment.js and JavaScript to get number of days in current month.
In this article, we’ll look at how to use moment.js and JavaScript to get number of days in current month.
How to use moment.js and JavaScript to get number of days in current month?
To use moment.js and JavaScript to get number of days in current month, we can use the daysInMonth
method.
For instance, we write
const numDaysInMonth = moment("2022-02", "YYYY-MM").daysInMonth();
to call daysInMonth
on a moment object with the year and month to get the number of days in a month.
Conclusion
To use moment.js and JavaScript to get number of days in current month, we can use the daysInMonth
method.