momentJS date string add 5 days momentJS date string add 5 days javascript javascript

momentJS date string add 5 days


UPDATED: January 19, 2016

As of moment 2.8.4 - use .add(5, 'd') (or .add(5, 'days')) instead of .add('d', 5)

var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');

Thanks @Bala for the information.

UPDATED: March 21, 2014

This is what you'd have to do to get that format.

Here's an updated fiddle

startdate = "20.03.2014";var new_date = moment(startdate, "DD-MM-YYYY").add('days', 5);var day = new_date.format('DD');var month = new_date.format('MM');var year = new_date.format('YYYY');alert(day + '.' + month + '.' + year);

ORIGINAL: March 20, 2014

You're not telling it how/what unit to add. Use -

 var new_date = moment(startdate, "DD-MM-YYYY").add('days', 5);


moment(moment('2015/04/09 16:00:00').add(7, 'd').format('YYYY/MM/DD HH:mm:ss'))

has to format and then convert to moment again.


The function add() returns the old date, but changes the original date :)

startdate = "20.03.2014";var new_date = moment(startdate, "DD.MM.YYYY");new_date.add(5, 'days');alert(new_date);