getMonth in javascript gives previous month

Because getmonth() start from 0. You may want to have d1.getMonth() + 1 to achieve what you want.

Leave a Comment