【发布时间】:2019-10-18 21:25:35
【问题描述】:
如果存储在 mongodb 数据库中的日期早于当前系统/服务器时间,我有下面的代码将 offer_status 更新为“过期”;
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 日,而 old_date_in_db 是 2019 年 8 月 1 日,则上述查询不会将报价状态更新为“已过期”。我不明白为什么? 像 2019 年 10 月 15 日这样的日期会将状态更新为“已过期”,而像“2019 年 8 月 1 日”这样的日期不会。
【问题讨论】: