The code is very simple, so I won’t go into too much nonsense, just give me the code:
/**
* * Realize that the current date is the first week of the year, and then push forward and backward by a few weeks
* The js array stores the two weeks before and after the current date (a total of five weeks of data)
**/
var initSearchMajorChanges = function(){
//Realize that the current date is the first week of the year, and then push forward and backward by a few weeks. The js array saves the two weeks before and after the current date (a total of five weeks of data)
var vv='2015-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 day of the 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 two weeks before and after the current date week (a total of five weeks of data). The above is the core code!
The method of use is also very simple, I hope everyone will like it.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn