Javascript 我想将时间戳与当前时间减去一个月进行比较

Javascript 我想将时间戳与当前时间减去一个月进行比较,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我正在从数据库中提取一个名为expiration_date的时间戳,我需要检查所述时间是否距离当前日期不到一个月 db.collection('inventory/clubs/MUCK').where("expiry_date", "<=", Date.now()-2592000000) //check the database for every date less than a month from the present. .get() .then(function(querySna

我正在从数据库中提取一个名为expiration_date的时间戳,我需要检查所述时间是否距离当前日期不到一个月

db.collection('inventory/clubs/MUCK').where("expiry_date", "<=", Date.now()-2592000000) //check the database for every date less than a month from the present.
.get()
.then(function(querySnapshot){
    var count = 0;
    querySnapshot.forEach(function(doc){
        count++; //increment for every hit.
    });
    console.log(count);
});

db.collection('inventory/clubs/MUCK')。其中(“expiration_date”,“使用Firestore时,您不能像现在这样将时间戳类型字段与整数值进行比较。您需要为查询构建Firestore时间戳或JavaScript日期对象

where("expiry_date", "<=", new Date(Date.now() - some_delta))

其中(“到期日”强制提醒:不是每个月都是30天,不是每天都是24小时,不是每个小时都是60秒。我不确定我的想法是否正确,但我会做一些事情,比如让今天的日期减去/加上1,然后根据需要进行比较。您的
到期日
以什么格式存储在db中。它是mil格式的吗liseconds格式或DD-MM-YYYY格式或其他格式?@zerkms它不需要精确,它在到期前设置为30天,这对我所需要的很好for@Dora这就是我想做的,只是需要理解为什么它不起作用,而且delta只是一个从日期中减去的以毫秒为单位的整数吗日期对象的表示,是。