I
I
Ivan Ivanov2019-07-12 13:35:06
JavaScript
Ivan Ivanov, 2019-07-12 13:35:06

How to find the number of days in a month?

I am writing a calendar, I need to create arrays (12 months) in an array using a loop, and I can’t understand how I should write a condition so that each array (month) writes as many elements (days) as it has (in each month same number of days).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-07-12
@IvanInvanov

//январь'19
(new Date(2019, 1, 0)).getDate() // 31

//февраль'19
(new Date(2019, 2, 0)).getDate() // 28

//февраль'16 високосный
(new Date(2016, 2, 0)).getDate() // 29

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question