Javascript Date method inconsistency - getDate vs getMonth

后端 未结 4 1271
旧时难觅i
旧时难觅i 2021-01-11 10:31

This caused me a bit of a headache last night and I wanted to understand why the getDate method in the Date object is 1 based (returns values from 1-31) while the getMonth m

4条回答
  •  孤独总比滥情好
    2021-01-11 10:35

    I suppose months are 0-based because Java did it the same way when the JavaScript language was designed.

    EDIT Oracle took down older Java documentation, there is an archived version of that page.

提交回复
热议问题