Jordan
Jordan

Reputation: 359

MongoDB create date get month issue?

Can someone please shed some light on why when I create a date object I receive the wrong month like so:

new Date("2013-11-25").getMonth()

output> 10

new Date("2013-11-25").toISOString()

output> 2013-11-25T00:00:00.000Z

I've seen this happen a couple of times and it's confusing me slightly. Is it a bug or am I missing something?

Upvotes: 1

Views: 1349

Answers (1)

Parvin Gasimzade
Parvin Gasimzade

Reputation: 26012

It is correct. This happens because in javascript month start from 0 not 1.

You can read in details here.

Upvotes: 2

Related Questions