I had the same issue and found that bumping up the increment of the
‘month’ and ‘year’ calculations fixed the issue with jumping to the next
year.var year = date.getFullYear(); var month = date.getMonth(); var day
= date.getDate(); month = ((month + months - 2) % 13) + 2;year +=
parseInt(month / 13); var days = daysInMonth(month, year);