momentJS date string add 5 days

前端 未结 9 1833
死守一世寂寞
死守一世寂寞 2020-12-23 09:03

i have a start date string \"20.03.2014\" and i want to add 5 days to this with moment.js but i don\'t get the new date \"25.03.2014\" in the alert window.

here my j

9条回答
  •  旧巷少年郎
    2020-12-23 09:27

    You can add days in different formats:

    // Normal adding
    moment().add(7, 'days');
    
    // Short Hand
    moment().add(7, 'd');
    
    // Literal Object    
    moment().add({days:7, months:1});
    

    See more about it on Moment.js docs: https://momentjs.com/docs/#/manipulating/add/

提交回复
热议问题