result_database = [
{ id: 1, name: "Tom Riddle", date: "2022-05-16T22:00:00.000Z" },
{ id: 2, name: "Hank Some", date: "2022-05-19T22:00:00.000Z" },
{ id: 3, name: "Family Man", date: "2022-05-17T22:00:00.000Z" },
];
var holiday_date = new Date().toJSON().slice(0, 10);
let holiday_date_remove = result_database.filter(
(item1) =>
!result_database.find(
(item2) =>
item1.name == item2.name && item2.date.slice(0, 10) == holiday_date
)
);
const holiday_result = [
...new Map(
holiday_date_remove.map((item) => [JSON.stringify(item.name), item])
).values(),
];
console.log(holiday_result);
I'm trying to .slice(0,10) the date. I get it displayed like this "2022-05-16T22:00:00.000Z", but I need it as "2022-05-16", so I try to date.slice(0, 10) it's not working though.