8

I was trying mongoExport with some date condition, I read here that date has to be in epoch format.

Question is,

I tried below,

> new Date(2013,10,16)
ISODate("2013-11-16T00:00:00Z")

Assuming that I gave Oct-16-2013, But it returned me '2013-11-16'. Same with epoch format also.

> new Date(2013,10,16)*1
1384560000000
> 
> new Date(1384560000000)
ISODate("2013-11-16T00:00:00Z")

Can you please help, why its changing the month to 11 ?

Community
  • 1
  • 1
Srivatsa N
  • 2,291
  • 4
  • 21
  • 36

1 Answers1

8

The month parameter of JavaScript's Date constructor is 0-based. So 0 for January to 11 for December, making it 9 for October instead of 10.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471