【问题标题】:MongoDB Compass - How To Insert Date Type?MongoDB Compass - 如何插入日期类型?
【发布时间】:2018-09-25 09:32:41
【问题描述】:

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

我试过这样:

但是正如你所看到的,有一个错误。

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

【问题讨论】:

    标签: mongodb mongodb-compass


    【解决方案1】:

    试试这样:

    2016-01-24T13:21:55.000
    

    【讨论】:

      【解决方案2】:

      试试这样:

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

      【讨论】:

        【解决方案3】:

        这样试试

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-01-21
          • 2014-09-24
          • 1970-01-01
          • 2021-02-03
          • 2015-06-30
          相关资源
          最近更新 更多