//date, based on the original date, increase days, by default 1 days functionadddate (date, days) {if(days = = Undefined | | days = = ") { days= 1; } varDate =Newdate (date); Date.setdate (Date.getdate ()+Days ); varmonth = Date.getmonth () + 1; varDay =date.getdate (); returnDate.getfullyear () + '-' + getformatdate (month) + '-' +getformatdate (day); } //Date Month/day display, if 1 digits, precede with ' 0 ' functionGetformatdate (ARG) {if(arg = = Undefined | | arg = = ") { return‘‘; } varRe = arg + '; if(Re.length < 2) {Re= ' 0 ' +re; } returnre; }
Reference:
Title, began to check the use of JS files, but did not find the function can be directly used, so I would like to write the function, which involves the judgment of the number of days per month, if it is February, but also related to the judgment of leap years, although not complex but I think JS should not be so low, so looked up the following information, Finally, the following significant discovery, in order to increase the number of days on a date, in fact, as long as the call Date object's Setdate () function can be, the method is as follows:
function Adddate (date,days) {
var d=new date (date);
D.setdate (D.getdate () +days);
var m=d.getmonth () +1;
return d.getfullyear () + '-' +m+ '-' +d.getdate ();
}
Where the date parameter is to be added and minus the day, the days parameter is to be added and minus the number, if the forward count is passed in negative numbers, the next count is passed in positive numbers, if the month is to be added and minus, call Setmonth () and getmonth () on it, It is important to note that the returned month is calculated starting at 0, which means that the returned month is one months less than the actual month, so add 1 accordingly.
JS date, Month: Date plus one Tian Deng