momentJS date string add 5 days

前端 未结 9 1855
死守一世寂寞
死守一世寂寞 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:20

    You can reduce what they said in a few lines of code:

    var nowPlusOneDay = moment().add('days', 1);
    var nowPlusOneDayStr = nowPlusOneDay.format('YYYY-MM-DD');
    
    alert('nowPlusOneDay Without Format(Unix Date):'+nowPlusOneDay);
    alert('nowPlusOneDay Formatted(String):'+nowPlusOneDayStr);
    

提交回复
热议问题