JS back today, tomorrow, yesterday's date
1 functionGetdatestr (adddaycount) {2 varDD =NewDate ();3Dd.setdate (dd.getdate () + Adddaycount);//get the date adddaycount days4 varYear =dd.getfullyear ();5 varMon = Dd.getmonth () +1;//Gets the date of the current month6 varDay =dd.getdate ();7 returnYear + "-" + Mon + "-" +Day ;8}
1 day before yesterday: Getdatestr ( -2); 2 yesterday: Getdatestr ( -1); 3 Today: Getdatestr (0); 4 Tomorrow: Getdatestr (1); 5 Day After Tomorrow: Getdatestr (2);
JS gets the last day of the month and the date of the first day
1 varNowdays =NewDate ();2 varYear =nowdays.getfullyear ();3 varmonth =nowdays.getmonth ();4 if(month==0)5 {6Month=12;7Year=year-1;8 }9 if(Month < 10) {Tenmonth = "0" +month; One } A varFirstDay = year + "-" + month + "-" + "01";//the first day of last month - - varMyDate =NewDate (year, month, 0); the varLastday = year + "-" + month + "-" + mydate.getdate ();//the last day of last month
JS get date yesterday, tomorrow and the last day of the month