mongodb 时间戳转日期格式统计

在日常中经常出现时间戳存在mongodb里的情况,以下就是根据时间戳转日期格式

生成数据


db.test.insert({ "id":20162,"create_time":1554195600,"time":"2019-04-02 17:00:00"});
db.test.insert({ "id":20159,"create_time":1552635000,"time":"2019-03-15 15:30:00"});
db.test.insert({ "id":20160,"create_time":1552632900,"time":"2019-03-15 14:55:00"});
db.test.insert({ "id":20161,"create_time":1552632900,"time":"2019-03-15 14:55:00"});
db.test.insert({ "id":20158,"create_time":1542798000,"time":"2018-11-21 19:00:00"});

查询数据

> db.test.find();
{ "_id" : ObjectId("5d0c9094e07a14a96b41b7c9"), "id" : 20162, "create_time" : 1554195600, "time" : "2019-04-02 17:00:00" }
{ "_id" : ObjectId("5d0c9094e07a1

你可能感兴趣的:(数据库,java,c#)