moment get month from date code example

Example 1: moment get month name

moment(monthNumber, 'M').format('MMMM')

Example 2: moment get month day

//The correct function to use is .date():

date.date() === 25;

Example 3: 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);

Tags:

Misc Example