setMonth(1) gives me March?

后端 未结 1 1980
抹茶落季
抹茶落季 2020-12-20 14:16

Why is setMonth(1) giving me March? I believe that 0=Jan, 1=Feb, 2=Mar






        
相关标签:
1条回答
  • 2020-12-20 15:08

    Today is the 31st of January. When you d.setMonth(1); you are trying to set the date to the 31st of February. Since this date doesn't exist, it falls over to the 3rd of March.

    Set the whole date when you initialise the object, don't try to change it piecemeal.

    0 讨论(0)
提交回复
热议问题