javascript - Get same weekend last year using moment js -
i'm trying same day of year last week can compare analytics.
using moment can this
var today = new date(); //sunday 4 september 2016 - week 36 var lastyear = new moment(today).subtract(12, 'months').todate(); //friday 4 september 2015 - week 37
what trying same 'sunday' last year, sunday week 36 2015
any idea how this?
here's came with:
let today = moment(); let lastyear = moment().subtract(1, 'year') .isoweek(today.isoweek()) .isoweekday(today.isoweekday());
it takes today start point, subtracts year, , sets week , weekday ones today.
so today (tue sept 13 2016, aka 2016-w37-2
) last year tue sept 8 2015 (aka 2015-w37-2
).
Comments
Post a Comment