How to get yesterday's date with Momentjs?

后端 未结 8 839
清酒与你
清酒与你 2021-01-30 08:08

So, my question is simple, how do I get yesterday\'s date with MomentJs ? In Javascript it is very simple, i.e.

today = new Date();
yesterday = new Date(today.se         


        
相关标签:
8条回答
  • 2021-01-30 08:35

    Yesterday's date in Momentjs in DD-MM-YYYY format.

    const yesterdaydate = moment().subtract(1, "days").format("DD-MM-YYYY");
    console.log(yesterdaydate)
    
    0 讨论(0)
  • 2021-01-30 08:40
    moment().add(-1, 'days');
    

    You can find more information in the docs.

    0 讨论(0)
提交回复
热议问题