如下,'stime' 和 'etime' 的类型是 'Date' 毫秒:
{
"_id" : ObjectId("58d843dd4da8fc62c8c6a0bd"),
"stime" : ISODate("2017-03-26T22:21:34.923Z"),
"etime" : ISODate("2017-03-26T22:42:17.341Z"),
}
我查询了这样的数据:
data.names<-c("stime","etime")
mongo.data <- mongo(collection = "data_1",db = "data_test",
url = "mongodb://10.23.102.122:32800")
journey <- mongo.data$find(query = '{\"_id\" : {\"$oid\":\"58d843dd4da8fc62c8c6a0bd\"}}',
fields = paste('{\"_id\":true, ',
paste('\"',data.names,'\":true', collapse = ', ', sep=''),
'}', sep = ''))
但是查询的数据是没有毫秒数据的UTC时间戳:
> journey
_id stime etime
1 58d843dd4da8fc62c8c6a0bd 1490566894 1490568137
> format(as.POSIXct(unlist(journey[1,-1]), origin = "1970-01-01 00:00:00"), format="%Y-%m-%d %H-%M-%OS3")
stime etime
"2017-03-27 06-21-34.000" "2017-03-27 06-42-17.000"
那么,如何查询毫秒级的数据呢?