|
The documentation shows the following code sample:
db.log.events.insert( {
|
"status": new Date('July 22, 2013: 13:00:00'),
|
"logEvent": 2,
|
"logMessage": "Success!",
|
} )
|
When I try it it doesn't recognise the date format
> db.irc.save( {
|
... "status": new Date('July 22, 2013: 14:00:00'),
|
... "logEvent": 2,
|
... "logMessage": "Success!",
|
... } )
|
> db.irc.find()
|
{ "_id" : ObjectId("5292784f25b5e2f57d9bd763"), "status" : ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ"), "logEvent" : 2, "logMessage" : "Success!" }
|
Removing the colon after "2013" is the correct way.
> db.irc.save( { "status": new Date('July 22, 2013 14:00:00'), "logEvent": 2, "logMessage": "Success!", } )
|
> db.irc.find()
|
{ "_id" : ObjectId("5292784f25b5e2f57d9bd763"), "status" : ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ"), "logEvent" : 2, "logMessage" : "Success!" }
|
{ "_id" : ObjectId("5292786625b5e2f57d9bd764"), "status" : ISODate("2013-07-22T04:00:00Z"), "logEvent" : 2, "logMessage" : "Success!" }
|
Note there are 2 code snippets on this page, both with the extra colon.
|