I got the following variables:
today = new Date();
date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
console.log(date)
------
Output
------
2021-9-6
How can I get the date from yesterday or 2 day ago? I tried:
console.log(today-2)
console.log(date-2)
------
Output
------
1630936602270
NaN
I expected the follwing output 2021-9-4