使用JSON.stringify
修改对象,添加键日期notif_sent_at
,并使用new Date()
的值存储在本地存储中const assignmentDetail = data.response.details.map(function (item) {
item['notif_sent_at'] = new Date();
item['notif_sent'] = false;
return item
})
,然后加载JSON.parse(),它是获取对象的assignmentDetail
"notif_sent": false,
"notif_sent_at": "2022-07-07T15:40:11.026Z",
当我比较日期时,我的期望是分钟
let today = new Date();
let diffMins = Math.round((((today - target.notif_sent_at) % 86400000) % 3600000) / 60000);
console.log(diffMins)
i got NaN
修改对象添加模板文字
target.notif_sent_at = `${new Date()}`;
和on比较函数解析Date.parse()
let today = new Date();
let diffMins = Math.round((((today - Date.parse(target.notif_sent_at)) % 86400000) % 3600000) / 60000);