Answers for "momentjs subtract months"

1

how 2 subtract 2 dates using moment.js

var date1 = moment('2016-10-08 10:29:23');
var date2 = moment('2016-10-08 11:06:55');
var diff = date2.diff(date1);
Posted by: Guest on February-23-2021
1

moment js get date 1 month

var currentDate = moment('2015-10-30');
var futureMonth = moment(currentDate).add(1, 'M');
var futureMonthEnd = moment(futureMonth).endOf('month');

if(currentDate.date() != futureMonth.date() && futureMonth.isSame(futureMonthEnd.format('YYYY-MM-DD'))) {
    futureMonth = futureMonth.add(1, 'd');
}

console.log(currentDate);
console.log(futureMonth);
Posted by: Guest on April-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language