New Date (); var New // Day before var New // Day after
A fully implemented approach in Wdatepicker
<class= "wdate" type= "text" ID= "Date_no" onchange = "onchangedate ();" name = "Date_no" onclick = "Wdatepicker ({maxdate: '%y-%m-{%d-1} ', isshowclear:false,readonly:true})" />
In JS, the following:
Date.prototype.format =function(format) {varargs = { "m+": This. GetMonth () + 1, "D+": This. GetDate (),"H +": This. GetHours (),"m+": This. getminutes (),"S+": This. getseconds (),"q+": Math.floor (( This. GetMonth () + 3)/3),//Quarter"S": This. getmilliseconds ()}; if(/(y+)/.test (format)) format = Format.replace (Regexp.$1, ( This. getFullYear () + ""). substr (4-regexp.$1. length)); for(varIinchargs) { varn =Args[i]; if(NewRegExp ("(" + i + ")"). Test (format)) format = Format.replace (regexp.$1, regexp.$1.length = = 1?). N: ("xx" + N). substr ("" +( N). length)); } returnformat; };
var New Date (); var New Date (Curdate.gettime ()-24*60*60*1000). Format ("YYYY-MM-DD"); $ ("#date_no"). Val (stringdate);
The above is yesterday and tomorrow's JS acquisition method.
Jsjs get the day before/after the current time (Yesterday/Tomorrow)