Job requirements, given the number of cycles for a year, you need to display the week's Monday and Sunday as well as the first and last day of the specified month
Baidu after finishing show posted, that the individual still do not understand why, I hope someone can explain
Post code:
<script type= "Text/javascript" >varIweek =function(year, week) {varD =NewDate (year, 0, 1);//Initialization Date D indicates the first day of the input year while(D.getday ()! = 1) {d.setdate (d.getdate ()+ 1); } varto =NewDate (year + 1, 0, 1)//Indicates the first day of the next yearvari = 1; vararr = '; for(varfrom = D; From <to ;) { if(i = =week) {arr+=from.getfullyear () + "/" + (From.getmonth () + 1) + "/" + from.getdate () + "-";
getFullYear () returns the year, GetMonth () returns the month, but the month defaults from 0, so +1;getdate () returns the day}varj = 6; while(J > 0) {from.setdate (from.getdate ()+ 1); if(i = =week) { if(j==1) {//If it is Sunday arr+=from.getfullyear () + "/" + (From.getmonth () + 1) + "/" +from.getdate (); //Arr.push (from.getfullyear () + "/" + (From.getmonth () + 1) + "/" + from.getdate ());}} J--; } if(i = =week) { returnarr; } from.setdate (From.getdate ()+ 1); I++; } } functionImonth (year, month) {varDay =NewDate (year,month,0); varTime = Day.getfullyear () + "/" + (Day.getmonth () + 1) + "/01-" +day.getfullyear () + "/" + (Day.getmonth () + 1) + "/" +day.getdate (); returnTime ; }</script>
js-displays the specified number of weeks in Monday and Sunday, the first and last day of the specified month-----------personal Baidu collation