日期:2014-05-16  浏览次数:20460 次

monogo 时间日期
> db.foo.insert({"x":new Date(2010,0,24,9,23,34)});             
> db.foo.insert({"x":new Date(2010,0,26,9,23,34)});
> db.foo.insert({"x":new Date(2010,0,27,9,23,34)});
> db.foo.insert({"x":new Date(2010,0,30,9,23,34)});
> db.foo.insert({"x":new Date(2010,1,02,9,23,34)});
>
> db.foo.find();                                       
{ "_id" : ObjectId("4d65bbec3ebb3cfc9ca664e0"), "x" : "Sun Jan 24 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bbf23ebb3cfc9ca664e1"), "x" : "Tue Jan 26 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bbf53ebb3cfc9ca664e2"), "x" : "Wed Jan 27 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bbf93ebb3cfc9ca664e3"), "x" : "Sat Jan 30 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bc023ebb3cfc9ca664e4"), "x" : "Tue Feb 02 2010 09:23:34 GMT+0800 (CST)" }
>
> db.foo.find({"x":{$lt:new Date(2010,0,27,9,23,34)}});
{ "_id" : ObjectId("4d65bbec3ebb3cfc9ca664e0"), "x" : "Sun Jan 24 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bbf23ebb3cfc9ca664e1"), "x" : "Tue Jan 26 2010 09:23:34 GMT+0800 (CST)" }
>
> db.foo.find({"x":{$gt:new Date(2010,0,27,9,23,34)}});
{ "_id" : ObjectId("4d65bbf93ebb3cfc9ca664e3"), "x" : "Sat Jan 30 2010 09:23:34 GMT+0800 (CST)" }
{ "_id" : ObjectId("4d65bc023ebb3cfc9ca664e4"), "x" : "Tue Feb 02 2010 09:23:34 GMT+0800 (CST)" }
>