How to get yesterday's date with Momentjs?

后端 未结 8 850
清酒与你
清酒与你 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:17

    You can easily subtract days from moment using

    var yesterday = moment().subtract(1, 'days')

    And for finding the previous date

    var previousDay = moment('2017/11/6', 'YYYY/MM/DD').subtract(1, 'days')

提交回复
热议问题