I would like a variable to hold yesterday\'s date in the format DD-MM-YYYY using Moment.js. So if today is 15-04-2015, I would like to subtract a day and have 1
Try this:
var duration = moment.duration({'days' : 1});
moment().subtract(duration).format('DD-MM-YYYY');
This will give you 14-04-2015 - today is 15-04-2015
Alternatively if your momentjs version is less than 2.8.0, you can use:
startdate = moment().subtract('days', 1).format('DD-MM-YYYY');
Instead of this:
startdate = moment().subtract(1, 'days').format('DD-MM-YYYY');