Date.prototype.getDay() is an integer number, between 0 and 6
Date.prototype.getMonth() also an integer number, between 0 and 11
then why Date.prototype.getDate() is the only function that between 1 and 31? why didn't it starts from 0 ?
Asked
Active
Viewed 130 times
1

Imesh Chamara
- 162
- 12
-
You should really ask MDN why ;) – Wais Kamal Feb 12 '21 at 17:23
-
@WaisKamal — Why? MDN just documents the language, it doesn't design it. – Quentin Feb 12 '21 at 17:24
-
"ruin the standard to make things easier", thanks @chazsolo – Imesh Chamara Feb 12 '21 at 17:32
1 Answers
-2
Because if you look at a calendar you'll notice that the first day of any month is 1 instead of 0.

Barbaldo
- 72
- 3
- 11
-
Also very related to this https://stackoverflow.com/questions/9687521/javascript-date-method-inconsistency-getdate-vs-getmonth – Barbaldo Feb 12 '21 at 17:29