0

I was debugging some error. While doing so I found some strange data in MongoDB as following.

{
    "_id" : ObjectId("5bea69494f5490b7e28b2d1d"),
    "date" : Date(-61562574238000)
}

I always thought the date in Mongo gets saved as follows.

{
    "_id" : ObjectId("5bea69494f5490b7e28b2d1d"),
    "date" : ISODate("2009-04-29T00:37:00.000Z")
}

Just wondering what is the reason behind it.

Pavan Kumar
  • 1,715
  • 1
  • 24
  • 48
  • 1
    Languages other than JavaScript can produce valid dates for BSON as well. Though out of range for a JavaScript translation, the date is likely : `Thursday, February 28, 0019 4:56:02 AM` in GMT of course. Perfectly valid and it happens everywhere. – Neil Lunn Nov 13 '18 at 06:19
  • Semi-related: [Iterating through PyMongo cursor throws InvalidBSON: year is out of range](https://stackoverflow.com/q/53177590/2313887) which shows an example of a date which would "blow up" python's `datetime`, but is of course still perfectly valid. – Neil Lunn Nov 13 '18 at 06:22

0 Answers0