admin管理员组

文章数量:1315851

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 ?

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 ?

Share Improve this question edited May 23, 2017 at 12:00 CommunityBot 11 silver badge asked Jan 10, 2014 at 0:35 Srivatsa NSrivatsa N 2,3214 gold badges24 silver badges37 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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.

本文标签: javascriptNew Date and ISO Date conversion in Mongo shellStack Overflow