How to remove item by expired date

ı have json and ı can sort earlier very well but also ı want to remove item if it is past day (ı mean expired date).

  .then(data => {
    this.products= data;
    this.products.sort((x,y) => new Date(x.start_time).getTime() - new Date(y.start_time).getTime());**// this is how to sort**

if it is expired date ; it want to delete automacally. so please help me


Search for array.sort for more info

1 Like

In addition to @Tommertom’s (typically) excellent advice, I would suggest looking at date-fns to handle the ... bits instead of the manual Date arithmetic you’re doing now.

1 Like

ı made something like this but its not worked


return product.start_time >= ‘2019-08-15 14:13:35’;
}).sort((x,y) => new Date(x.start_time).getTime() - new Date(y.start_time).getTime());

how can ı make this

Your date-time comparison (in the filter) is not correct, use the one you use for the sort or the one @rapropros is suggesting