[Vuejs]-I want to return filterd array that return objects with dates bigger than current date with vue

0👍

You should convert your e.date to a date to have a meaningful comparison. Otherwise you compare strings which doesn’t make sense.

const currentDate = new Date(new Date().toDateString());

const noneEndedCountdowns = computed(() => {
  // filters countdowns that only not ended
  return countdowns.value.filter((e) => {
    const [day, month, year] = e.date.split('-').reverse();
    const date = new Date(year, month - 1, day);
    return e.date >= currentDate;
  });
});

Leave a comment