我尝试查询expiration_date字段,该字段返回您今天的日期,我正在尝试使用该方法,但是它不返回任何结果
router.get('/date/expired/', async (req, res, next) => {
const start = new Date()
start.setHours(0, 0, 0, 0)
const end = new Date()
end.setHours(23, 59, 59, 999)
try {
const data = await Tarea.find({
fecha_vencimiento: {
$gte: start,
$lt: end
}
})
res.status(200).json({
data
})
} catch (err) {
next(err)
}
})
答案 0 :(得分:0)
尝试使用moment.js
定义日期:
let start = moment().format('YYYY-MM-DD')
let end = moment().add(1,'days').format('YYYY-MM-DD');
我希望它对您有用。