@ Сэм , попробуйте следующий код.
var data = [
{type: "recare", value: "Hello", date: "2018-06-05" },
{type: "tocall", value: "World", date: "2018-06-13" },
{type: "recare", value: "People", date: "2018-06-06"}
]
var date = new Date()
console.log(date)
var year = date.getFullYear()
var month = date.getMonth()
var day = date.getDate()
console.log(year, month, day)
var today = new Date(year, month, day)
console.log(new Date(data[0].date) >= today) // returns false
console.log(new Date(data[0].date) == today); //returns: true
console.log(new Date(data[1].date) > today); //returns: true
Вывод:
Tue Jun 05 2018 22:41:27 GMT+0200 (CEST)
2018 5 5
true
false
true
Обратите внимание на следующие 2 строки:коды, как указано выше решение основано на этом.
✓ Следующие 2 утверждения эквивалентны друг другу
console.log(new Date("2018-08-07"));
console.log(new Date(2018, 7, 7)); // month ranges from 0-11 in call to Date() contructor
Вывод:
Tue Aug 07 2018 02:00:00 GMT+0200 (CEST)
Tue Aug 07 2018 00:00:00 GMT+0200 (CEST)