var now = new Date (); //Current date var Nowdayofweek = Now.getday (); //today's Day of the week var NowDay = Now.getDate (); //Current Day var Nowmonth = Now.getmonth (); //Current month var nowYear = Now.getyear (); //Current year nowyear + = (Nowyear < 2000)? 1900:0; // var lastmonthdate = new Date (); //Last month date lastmonthdate.setdate (1); lastmonthdate.setmonth ( Lastmonthdate.getmonth ()-1); var lastyear = Lastmonthdate.getyear (); &nbsP; var lastmonth = Lastmonthdate.getmonth (); //formatted date:yyyy-mm-dd function formatdate (date) { var myyear = Date.getfullyear (); var mymonth = Date.getmonth () +1; var myweekday = date.getdate (); if (Mymonth <) { mymonth = "0" + mymonth; } if (Myweekday <) { myweekday = "0" + myweekday; } Return (myyear+ "-" +mymonth + "-" + myweekday); } //get the number of days in a month function Getmonthdays (mymonth) { var monthStartDate = new Date (Nowyear, Mymonth, 1); var monthenddate = new Date (nowYear, MyMonth + 1, 1); var days = (monthEndDate - monthstartdate)/( * 60 * 60 * 24); return days; } //get the start of the quarter function GetQuarterStartMonth () { var Quarterstartmonth = 0; if (nowmonth<3) { Quarterstartmonth = 0;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSp; if (2<6) { quarterstartmonth = 3; } if (5<9) { quarterstartmonth = 6; } if (nowMonth>8) { quarterstartmonth = 9; } return quarterstartmonth; } //today var getcurrentdate = new Date (NowYear, NowMonth, Nowday); var getcurrentdate = formatdate (getcurrentdate) //yesterday var getyesterdaydate = new Date (nowyear, Nowmonth, nowDay-1); &nbSp; var getyesterdaydate = formatdate (getyesterdaydate); //get start date of the week var getweekstartdate = new Date (nowyear, Nowmonth, Nowday-nowdayofweek); & Nbsp;var getweekstartdate = formatdate (getweekstartdate); //get this week's end date var getweekenddate = new Date (nowyear, Nowmonth, Nowday + (6-nowdayofweek)); var get Weekenddate = formatdate (getweekenddate); //get last week's start date var getupweekstartdate = new Date (nowyear, Nowmonth, nowday-nowdayofweek-7); var Getupweekstartdate = formatdate (getupweekstartdate); //get last week's end date var getupweekenddate = new Date (nowyear, Nowmonth, Nowday + (6-nowdayofweek-7)); va R getupweekenddate = formatdate (getupweekenddate); //Get start date of this month var getmonthstartdate = new Date (Nowyear, Nowmonth, 1); var getmonthstartdate = formatdate (getmonthstartdate); //get end date for this month var getmonthenddate = new Date (nowyear, Nowmonth, Getmonthdays (nowmonth)); var getmonthenddate = formatdate (getmonthenddate); //get last month start time var getlastmonthstartdate = new Date (Nowyear, Lastmonth, 1); var Getlastmonthstartdate = FormatDate (getlastmonthstartdate); //get last month end time var getlastmonthenddate = new Date (nowyear, Lastmonth, Getmonthdays (lastmonth)); var getlastmonthenddate = formatdate (getlastmonthenddate);
JS Get Date