Issue
I have the following array:
[
{
Id: 1,
Name: "AI",
Capacity: 2,
From: "2021-10-27T08:00:00",
To: "2021-10-27T08:50:00",
},
{
Id: 2,
Name: "TEST",
Capacity: 2,
From: "2021-10-28T09:10:00",
To: "2021-10-28T09:20:00",
},
]
How can I filter my results to only get items where the From
property includes 2021-10-28
?
Solution
Try this:
const data = [{
"Id": 1,
"Name": "AI",
"Capacity": 2,
"From": "2021-10-27T08:00:00",
"To": "2021-10-27T08:50:00"
},
{
"Id": 2,
"Name": "TEST",
"Capacity": 2,
"From": "2021-10-28T09:10:00",
"To": "2021-10-28T09:20:00"
}
];
const result = data.filter((e) => e.From.slice(0, 10) === "2021-10-28");
console.log(result);
Answered By - Behemoth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.