How would one use moment.js to get the number of days in the current month? Preferably without temporary variables.
Moment has a daysInMonth function:
daysInMonth
Days in Month 1.5.0+ moment().daysInMonth(); Get the number of days in the current month. moment("2012-02", "YYYY-MM").daysInMonth() // 29 moment("2012-01", "YYYY-MM").daysInMonth() // 31
Days in Month 1.5.0+
moment().daysInMonth();
Get the number of days in the current month.
moment("2012-02", "YYYY-MM").daysInMonth() // 29 moment("2012-01", "YYYY-MM").daysInMonth() // 31
2.1m questions
2.1m answers
60 comments
57.0k users