How to get yesterday date in node.js backend?

后端 未结 8 977
误落风尘
误落风尘 2021-02-09 14:00

I am using date-format package in node back end and I can get today date using

var today = dateFormat(new Date());

In the same

8条回答
  •  太阳男子
    2021-02-09 14:19

    Try this:

    var d = new Date(); // Today!
    d.setDate(d.getDate() - 1); // Yesterday!
    

提交回复
热议问题