Last day of month?
Write a function
getLastDayOfMonth(year, month) that returns the last day of month. Sometimes it is 30th, 31st or even 28/29th for Feb.
year– four-digits year, for instance 2012.
month– month, from 0 to 11.
getLastDayOfMonth(2012, 1) = 29 (leap year, Feb).
Let’s create a date using the next month, but pass zero as the day:
Normally, dates start from 1, but technically we can pass any number, the date will autoadjust itself. So when we pass 0, then it means “one day before 1st day of the month”, in other words: “the last day of the previous month”.