-1

我在集合中有一个 conn_time 字段,需要使用 mongo export 从集合中导出最后 15 分钟的数据。conn_time 日期为 ISO 格式。日期格式,如 2013-06-11T07:18:00Z。我尝试过使用 JavaScript 但无法正常工作

var enDdate = new Date(); enDdate.toISOString()
var startDate = new Date(endDate-15*60*1000); startDate.toISOString();
4

1 回答 1

0

You can check out this question: mongoDb return results based on time interval

You have to escape the spec chars. I could not make it run with the ISODate helper but like this

"{date:{\$gt:{ \"\$date\" : 1370935140000 }}}"

given as a -q parameter to the mongoexport works fine. This case 1370935140000 is the unix timestamp in mili secs. So you have to calculate the unixtimestamp 15 mins before than add 000 at the and and go on with this. I will try to resolve also with the ISODate.

于 2013-09-09T08:11:02.120 回答