new date previous day code example
Example 1: js yesterday date
var d = new Date();
d.setDate(d.getDate() - 1);
Example 2: js date of yesterday
let today = new Date();
let yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
console.log('Today: ' + today);
console.log('Yesterday: ' + yesterday);