Moment JS - how to subtract 7 days from current date?
May be:
dateTo = moment().format('YYYY-MM-DD');
dateFrom = moment().subtract(7,'d').format('YYYY-MM-DD');
moment#subtract
You can use:
moment().subtract(1,'w')
to subtract one week (7 days) from the current date.
NOTE:
1. w for week
2. d for days
3. M for month
4. y for year
The date object, when casted, is in milliseconds. so:
dateFrom = moment(Date.now() - 7 * 24 * 3600 * 1000).format('YYYY-MM-DD');