programming-examples/js/Date/Write a JavaScript function to calculate 'yesterday day'..js

7 lines
265 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
var yesterday = function(date1){
var dt = new Date(date1);
return new Date((dt.setDate(dt.getDate()-1))).toString();
}
console.log(yesterday('Nov 15, 2014'));
console.log(yesterday('Nov 16, 2015'));
console.log(yesterday('Nov 17, 2016'));