MongoDB指南针 - 如何插入日期类型?

时间:2018-04-15 15:49:12

标签: mongodb mongodb-compass

使用MongoDB Compass将文档插入MongoDB数据库时如何插入当前日期?

我试过这样:

enter image description here

但是你可以看到有一个错误。

如何使用MongoDB Compass插入当前日期?

3 个答案:

答案 0 :(得分:1)

尝试这样

{
"type": "grunt",
"last_used": {"$date":{"$numberLong":"1602720972129"}},
"created_at":{"$date":{"$numberLong":"1602720972129"}}
}

答案 1 :(得分:0)

尝试这样的“ 2016-01-24T13:21:55.000”

谢谢

答案 2 :(得分:0)

尝试这样:

{
"type":"grunt",
"last_used": {
        "$date": "2018-04-15T16:54:40.000Z"
    },
"created_at": {
        "$date": "2018-04-15T16:54:40.000Z"
    }
}