What is the syntax for Dates in MongoDB running on MongoLab?

落花浮王杯 提交于 2019-12-05 11:02:38

If you are using one of the drivers, you create a date via that language's Date class. For instance, in Javascript (like Node.js) it would be 'new Date(11,11,11)'. If using the MongoLab REST API or admin UI you represent dates with this syntax:

  { "$date": "2010-10-28T23:07:11Z" }

Also if an item has:

"dateAdded": {
   "$date": "2012-07-30T15:26:15.321Z"
}

in one of it's entries, then you can find it by searching:

{
    "dateAdded": {
        "$gt": {
            "$date": "2012-07-28T23:07:11Z"
        }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!