在下面的代码中,数据库中的日期是 date
类型:
function remainderCheck() {
$interval(function() {
var i = 0;
for (i; i < $scope.notes.length; i++) {
var currentDate = moment().format('YYYY-MM-DD HH:mm');
console.log("currentDate" + currentDate);
// console.log($scope.notes[i].title);
var dateString = (new Date($scope.notes[i].remainder));
var dateString2=new
Date(dateString).toISOString().slice(0, 19).replace('T', ' ');
console.log("database date::"+dateString2);
if (dateString2 > currentDate) {
console.log($scope.notes[i].description);
console.log("reminder !!!!! ");
toastr.success('Remainder heck notes!!!');
}
console.log("dskjhdjkh");
}
}, 10000);
}
remainderCheck();
如何比较这两个日期?
currentDate2017-11-29 15:26
database date::2017-11-13 18:30:00
上面显示了代码的输出,但我无法将两者进行比较。
如果两个时间相同,我想启用烤面包机。
发布于 2017-11-30 13:16:29
关于
仅限比较日期
var dbDate='2017-11-23 18:30:00';
if(moment().format('YYYY-MM-DD')==moment(dbDate).format('YYYY-MM-DD'))
alert("Equal")
else
alert("Not equal")
DateTime比较
var dbDate='2017-11-23 18:30:00';
if(moment().format('YYYY-MM-DD HH:mm')==moment(dbDate).format('YYYY-MM-DD HH:mm'))
alert("Equal")
else
alert("Not equal")
https://stackoverflow.com/questions/47566238
复制相似问题