Node.js node js比较mongodb数据库时间和服务器的当前时间
如果mongodb数据库中存储的日期早于当前系统/服务器时间,我有下面的代码将状态更新为“过期”Node.js node js比较mongodb数据库时间和服务器的当前时间,node.js,mongodb,Node.js,Mongodb,如果mongodb数据库中存储的日期早于当前系统/服务器时间,我有下面的代码将状态更新为“过期” dbo.collection("offers").updateMany({older_date_in_DB:{$lt: current_system_time}, {$set: {offerStatus:"EXPIRED"}}, (err,response)=>{ if(err) throw err; console.log(re
dbo.collection("offers").updateMany({older_date_in_DB:{$lt: current_system_time},
{$set:
{offerStatus:"EXPIRED"}},
(err,response)=>{
if(err) throw err;
console.log(response.modifiedCount)
})
但是,我注意到,如果当前日期为2019年10月18日,而数据库中较旧的日期为2019年8月1日,则上述查询不会将报价状态更新为“过期”。我不明白为什么?
2019年10月15日之类的日期会将状态更新为“过期”,而2019年8月1日之类的日期则不会 请使用以下行在mongodb中比较日期条件
{ older_date_in_DB: { $lt: new Date('10/18/2019') } }
如果值为dateFormat,则使用new关键字