/*calculates the Monday and Sunday return=>{mondy:date,sundy:date} parms:{date for a specified time: The specified time, or the current time if not specified } */ functionGetweekarea (date) {if(! (DateinstanceofDate)) {Date=NewDate (); } varDay = Date.getday (), _date =date.getdate (), Mondy= _date-(Day = = 0? 7:day) + 1, T1=NewDate (Date.gettime ()), T2=NewDate (Date.gettime ()); T1.setdate (Mondy); T2.setdate (Mondy+ 6); return{mondy:t1, sundy:t2}; } functionFnsetweek (week) {varWeekarea = Getweekarea (), Mondy = Weekarea.mondy, Sundy = weekarea.sundy, week = parseint (week, 10); if(IsNaN (week)) {/*Zhou Yicha data for last week*/ vart =NewDate (), day =T.getday (); returnFnsetweek (Day = = 1? -1:0); } Else{mondy.setdate (mondy.getdate ()+ Week * 7); Sundy.setdate (Sundy.getdate ()+ Week * 7); } starttime.val (Mondy.formatdate (DateFormat)); Endtime.val (Sundy.formatdate (DateFormat)); }
JS for the specified time of Monday and Sunday