Js get the specified date (today, yesterday, the day after tomorrow), js get
Js obtains the specified date (today, yesterday, and the day after tomorrow), and uses js to obtain a specified date, such as today and tomorrow.
Function getDate (AddDayCount) {var dd = new Date (); dd. setDate (dd. getDate () + AddDayCount); // obtain the date var y = dd after AddDayCount. getFullYear (); var m = dd. getMonth () + 1; // obtain the date var d = dd of the current month. getDate (); return y + "-" + (m <10? "0" + m: m) + "-" + (d <10? "0" + d: d );}
Here, AddDayCount refers to the date from today, 0 indicates today, and 1 indicates tomorrow;
GetFullYear () gets the Year;
GetMonth () + 1; // get the date of the current month
GetDate (); get the date number;
Because the obtained value is an integer, the standard format of yyyy-MM-dd is not obtained. Therefore, we need to judge m <10? "0" + m: m.