get next week start and end using jquery and moment js

前端 未结 4 1277
灰色年华
灰色年华 2020-12-08 02:47

I searched for this question and found there is a no answer on Stackoverflow.. So I decided to answer it...

This question helps if you need to get the start/end of n

4条回答
  •  攒了一身酷
    2020-12-08 03:31

        //Last week (get current week array list from momentjs)
        var sd = moment(currentWeekFd[0]).subtract(7, 'days').format();
        var ed = moment(currentWeekEd[6]).subtract(7, 'days').format();
        var lastWeekStratDay = moment(sd).format('YYYY-MM-DD');
        var lastWeekEndDay = moment(ed).format('YYYY-MM-DD');
        console.log(lastWeekStratDay +', '+ lastWeekEndDay)
    
        //Next week
        var sd = moment(currentWeekFd[0]).add(7, 'days').format();
        var ed = moment(currentWeekEd[6]).add(7, 'days').format();
        var nextWeekStratDay = moment(sd).format('YYYY-MM-DD');
        var nextWeekEndDay = moment(ed).format('YYYY-MM-DD');
        console.log(nextWeekStratDay +', '+ nextWeekEndDay)
    

提交回复
热议问题