This article mainly introduces the week when moment. js is easy to get the current date. If you need it, you can refer to the code below. It is very simple and you don't need to talk about it. Here is the code:
The Code is as follows:
/**
* The current date is the week of the current year, and a few weeks are pushed forward and backward.
* The js array stores the data of the first two weeks (five weeks in total) of the current date)
**/
Var initSearchMajorChanges = function (){
// The current date is the week of the current year, and then the weeks are pushed forward and backward. The js array stores the data of the previous two weeks (five weeks in total) of the current date)
Var vv = '2017-02-07 ';
Var vNowDate = moment (new moment (vv ). format ("YYYY-MM-DD "));//. add ('month', 0 ). add ('days ',-1 );
Var vWeekOfDay = moment (vNowDate). format ("E"); // calculate the week number of this week
Var vWeekOfDays = 7-vWeekOfDay-1;
Var vStartDate = moment (vNowDate). add ('days ', vWeekOfDays );
Var vEndDate = moment (vNowDate). add ('days ',-vWeekOfDay );
Var vStartDateNew = moment (vStartDate). add ('days ', 7 * $ scope. gWeeks );
Var vEndDateNew = moment (vEndDate). add ('days ',-(7 * $ scope. gWeeks ));
// Var vYearAndWeek = moment (vStartDate). format ("YYYY") + '-' + moment (vStartDate). format ("WW ");
SearchMajorChanges (vStartDateNew, vEndDateNew );
}
Requirements:
The js array stores the data of the first two weeks (five weeks in total) of the current date week. The above is the core code!
It is easy to use and I hope you will like it.