1<script>2 varnow =NewDate ();//Current Date3 varNowdayofweek = Now.getday ();//the day of the week today4 varNowday = Now.getdate ();//Current Day5 varNowmonth = Now.getmonth ();//Current Month6 varNowyear = Now.getyear ();//Current year7Nowyear + = (Nowyear < -) ?1900:0;// 8 9 //formatted Date: YYYY-MM-DDTen function FormatDate (date) { One varMyyear =date.getfullyear (); A varMymonth = Date.getmonth () +1; - varMyweekday =date.getdate (); - the if(Mymonth <Ten){ -Mymonth ="0"+Mymonth; - } - if(Myweekday <Ten){ +Myweekday ="0"+Myweekday; - } + return(myyear+"-"+mymonth +"-"+myweekday); A } at - //get the number of days in a month - function Getmonthdays (mymonth) { - varMonthstartdate =NewDate (Nowyear, Mymonth,1); - varMonthenddate =NewDate (nowyear, Mymonth +1,1); - varDays = (monthenddate-monthstartdate)/( +* -* -* -); in returnDays ; - } to + //get the start month of the quarter - function Getquarterstartmonth () { the varQuarterstartmonth =0; * if(nowmonth<3){ $Quarterstartmonth =0; Panax Notoginseng } - if(2<nowmonth && nowmonth<6){ theQuarterstartmonth =3; + } A if(5<nowmonth && nowmonth<9){ theQuarterstartmonth =6; + } - if(nowmonth>8){ $Quarterstartmonth =9; $ } - returnQuarterstartmonth; - } the - //get the start date for this weekWuyi function Getweekstartdate () { the varWeekstartdate =NewDate (Nowyear, Nowmonth, Nowday-Nowdayofweek); - returnformatdate (weekstartdate); Wu } - About //Get the end date for this week $ function Getweekenddate () { - varWeekenddate =NewDate (Nowyear, Nowmonth, Nowday + (6-Nowdayofweek)); - returnformatdate (weekenddate); - } A + //get the start date for this month the function Getmonthstartdate () { - varMonthstartdate =NewDate (Nowyear, Nowmonth,1); $ returnformatdate (monthstartdate); the } the the //Get the end date for this month the function Getmonthenddate () { - varMonthenddate =NewDate (Nowyear, Nowmonth, Getmonthdays (Nowmonth)); in returnformatdate (monthenddate); the } the About //get the start date for the quarter the function Getquarterstartdate () { the the varQuarterstartdate =NewDate (Nowyear, Getquarterstartmonth (),1); + returnformatdate (quarterstartdate); - } the Bayi //or the end date of the quarter the function Getquarterenddate () { the varQuarterendmonth = Getquarterstartmonth () +2; - varQuarterstartdate =NewDate (Nowyear, Quarterendmonth, Getmonthdays (Quarterendmonth)); - returnformatdate (quarterstartdate); the } the the alert (Getquarterenddate ()); the</script>
JS gets this week, this month, the start date and end date for this quarter