from Date I just want to subtract 1 day in javascript/angularjs

前端 未结 3 1279
暖寄归人
暖寄归人 2021-02-04 09:05

with the help of new Date() how i can achieve this. my code :

var temp =new Date(\"October 13, 2014 22:34:17\");
console.log(new Date(temp-1));

3条回答
  •  你的背包
    2021-02-04 09:57

    You can simply subtract one day from today date like this:

    var yesterday = new Date(new Date().setDate(new Date().getDate()-1));
    

提交回复
热议问题