Format date and Subtract days using Moment.js

后端 未结 7 881
别那么骄傲
别那么骄傲 2020-11-29 20:28

I would like a variable to hold yesterday\'s date in the format DD-MM-YYYY using Moment.js. So if today is 15-04-2015, I would like to subtract a day and have 1

7条回答
  •  悲&欢浪女
    2020-11-29 21:18

    In angularjs moment="^1.3.0"

    moment('15-01-1979', 'DD-MM-YYYY').subtract(1,'days').format(); //14-01-1979
    or
    moment('15-01-1979', 'DD-MM-YYYY').add(1,'days').format(); //16-01-1979
    ``
    
    
    
    

提交回复
热议问题