I'm trying to subtract a day from this date format yyyy-mm-dd (string) but can't figure out any way to achieve that using javascript.
What I tried
dateISO = new Date(form.date);
dateISO.setDate(dateISO.getDate() - 1);
I'm trying to subtract a day from this date format yyyy-mm-dd (string) but can't figure out any way to achieve that using javascript.
What I tried
dateISO = new Date(form.date);
dateISO.setDate(dateISO.getDate() - 1);
Your code works.
const form = {date: '2020-12-04'}
const dateISO = new Date(form.date);
console.log(dateISO);
dateISO.setDate(dateISO.getDate() - 1);
console.log(dateISO);