Javascript - Get Previous Months Date

后端 未结 6 902
情深已故
情深已故 2021-02-14 12:25

If i have a variable that returns a date, in the format of dd MMM yyyy, so 28 Aug 2014, how can i get the date of the previous month.

I can modify the month via:

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 12:59

    You could use moment.js subtract function for this.

    var day = moment("2014-08-28");
    day.subtract(1, 'months');
    

提交回复
热议问题