如何在mongodb中将日期时间从epoc转换为utc

时间:2016-07-14 12:20:36

标签: json mongodb datetime mongodb-query robo3t

大家好我有一个集合名称test_data,在这个集合中我有像给定的格式一样的数据

Data =  [{
    "_id" : "53fe7ae0ef038fee879263d5",
    "chanal_id" : "can1",
    "instrumentnam" : "New Demo Device",
    "siteid" : "53fe741d66455060e003c2d8",
    "locationid" : "53fe74a866455060e003c2db",
    "timestamp" : 1406916000,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "5",
    "people" : [ 
        {
            "id" : 1,
            "age" : 23,
            "gender" : "male",
            "ethnicity" : null,
            "mood" : "happy",
            "ethnicity_mod" : "White",
            "mood_mod" : "Happy",
            "gender_mod" : "Female",
            "age_mod" : 22
        }
    ],
    "dateUTC" : 1409190000
},


{
    "_id" : "53fe7ae0ef038fee879263d6",
    "chanel_id" : "can1",
    "instrumentnam" : "New Demo Device",
    "siteid" : "53fe741d66455060e003c2d8",
    "locationid" : "53fe74a866455060e003c2db",
    "timestamp" : 1406917800,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "5",
    "people" : [ 
        {
            "id" : 2,
            "age" : 16,
            "gender" : "female",
            "ethnicity" : null,
            "mood" : "happy",
            "ethnicity_mod" : "White",
            "mood_mod" : "Happy"
        }
    ],
    "dateUTC" : 1409186528
},

{
    "_id" : "53fe7ae0ef038fee879263d7",
    "chanal_id" : "can1",
    "instrumentnam" : "New Demo Device",
    "siteid" : "53fe741d66455060e003c2d8",
    "locationid" : "53fe74a866455060e003c2db",
    "timestamp" : 1406918800,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "5",
    "people" : [ 
        {
            "id" : 3,
            "age" : 33,
            "gender" : "male",
            "ethnicity" : null,
            "mood" : "happy",
            "ethnicity_mod" : "White"
        }
    ],
    "dateUTC" : 1409186528
}
,

{
    "_id" : "53fe7ae0ef038fee879263d8",
    "chanal_id" : "can1",
    "instrumentnam" : "New Demo Device",
    "siteid" : "53fe741d66455060e003c2d8",
    "locationid" : "53fe74a866455060e003c2db",
    "timestamp" : 1406919800,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "5",
    "people" : [ 
        {
            "id" : 4,
            "age" : 45,
            "gender" : "female",
            "ethnicity" : null,
            "mood" : "happy",
            "age_mod" : 5
        }
    ],
    "dateUTC" : 1409186528
},


{
    "_id" : "53fe7ae0ef038fee879263d9",
    "chanal_id" : "can1",
    "instrumentnam" : "New Demo Device",
    "siteid" : "53fe741d66455060e003c2d8",
    "locationid" : "53fe74a866455060e003c2db",
    "timestamp" : 1406920800,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "5",
    "people" : [ 
        {
            "id" : 5,
            "age" : 14,
            "gender" : "female",
            "ethnicity" : null,
            "mood" : "angry"
        }
    ],
    "dateUTC" : 1409186528
},


{
    "_id" :"53ff927266455060e003c2e0",
    "chanal_id" : "rtsp://192.168.1.83:554/live.sdp",
    "instrumentnam" : "Test Device",
    "siteid" : "53f62abf66455068373665ff",
    "locationid" : "53f62bb86645506837366603",
    "timestamp" : 1409258116,
    "status" : "online",
    "msgtype" : "demographics",
    "fps" : "32",
    "people" : [],
    "dateUTC" : 1409258098
}]

是json格式, 我想做什么 1.我想在linux系统中将时间戳从epoc时间转换为utc时间。和 2.我想在linux系统中使用mongodb代码将这个json数据转换为csv格式。

所以有人可以帮我解决这个问题。

0 个答案:

没有答案