Reputation: 8948
When inserting a document into a MongoDB database with MongoDB Compass how do I insert the current date?
I have tried like so:
But as you can see there is an error.
How do I insert the current date using MongoDB Compass?
Upvotes: 18
Views: 27810
Reputation: 86
Try like this
{
"type": "grunt",
"last_used": {"$date":{"$numberLong":"1602720972129"}},
"created_at":{"$date":{"$numberLong":"1602720972129"}}
}
Upvotes: 1
Reputation: 391
Try like this:
{
"type":"grunt",
"last_used": {
"$date": "2018-04-15T16:54:40.000Z"
},
"created_at": {
"$date": "2018-04-15T16:54:40.000Z"
}
}
Upvotes: 26