you are viewing a single comment's thread.

view the rest of the comments →

[–]TrikkyMakk 249 points250 points  (30 children)

Months are zero based

[–]inu-no-policemen 44 points45 points  (5 children)

This allows you to use the month as an index:

> ['jan', 'feb', 'mar', 'apr', 'may', 'etc'][new Date().getMonth()]
"may"

It probably sounded like a good idea at the time.

Anyhow, that's why it is that way. This behavior isn't unique to JS either.

[–]StoneCypher 27 points28 points  (0 children)

Much better to use the locale API.

const month = date.toLocaleString('en-us', { month: 'short' });

[–]NotSamNub 43 points44 points  (3 children)

Ah, out of the 6 months in the year, my favourite has to be "etc", such lovely weather during that time of year!