You need to use it in your project and write one yourself. JavaScript date is reduced by month
Method Two:
<script language= "JavaScript" > Date.prototype.Format = function (FMT) {//Code author: meizz var o = {"m+": This.getmo Nth () + 1,//month "d+": this.getdate (),//day "h+": this.gethours (),//hr "m+": this.getminutes (),//min "s+": this.gets
Econds (),//sec "q+": Math.floor (This.getmonth () + 3)/3),//Quarter "S": this.getmilliseconds ()//millisecond};
if (/(y+)/.test (FMT)) FMT = Fmt.replace (regexp.$1, (this.getfullyear () + ""). substr (4-regexp.$1.length)); For (var k in O) if (new RegExp ("+ K +")). Test (FMT)) FMT = Fmt.replace (regexp.$1, (regexp.$1.length = 1)?
(O[k]): (("+ o[k]"). substr (("" + o[k). length));
return FMT;
} Date.prototype.addDays = function (d) {this.setdate (this.getdate () + D);};
Date.prototype.addWeeks = function (w) {this.adddays (w * 7); date.prototype.addmonths= function (m) {var d = this.getdate (); This.setmonth (This.getmonth () + m); if (This.getdate () ;
d) this.setdate (0);
}; Date.prototype.addYears = function (y) {var m = this.getmonth (); thiS.setfullyear (This.getfullyear () + y);
if (M < This.getmonth ()) {this.setdate (0);}}; </script>
Method Three:
<script> function DateAdd (interval,number,date) {/* *---------------DateAdd (interval,number,date)-------
----------* DATEADD (interval,number,date) * Function: To achieve VBScript DateAdd function.
* Parameter: interval, a string expression representing the time interval to add.
* Parameter: number, numeric expression, representing the amount of time interval to add.
* Parameter: Date, Time object.
* Return: A new Time object.
* var now = new Date ();
* var newdate = DateAdd ("D", 5,now); * AUTHOR:WANGHR100 (Grey bean baby. NET) * update:2004-5-28 11:46 *---------------DateAdd (interval,number,date)------------ -----*/Switch (interval) {case "Y": {date.setfullyear (Date.getfullyear () +number)
;
return date;
Break
Case "Q": {Date.setmonth (Date.getmonth () +number*3);
return date;
Break
Case "M": {Date.setmonth (Date.getmonth () +number);
return date;
Break Case "W": {DAte.setdate (Date.getdate () +number*7);
return date;
Break
Case "D": {Date.setdate (Date.getdate () +number);
return date;
Break
Case "H": {date.sethours (date.gethours () +number);
return date;
Break
Case "M": {date.setminutes (Date.getminutes () +number);
return date;
Break
Case "S": {date.setseconds (Date.getseconds () +number);
return date;
Break
} default: {Date.setdate (D.getdate () +number);
return date;
Break
}} var now = new Date ();
Plus five days.
var newdate = DateAdd ("D", 5,now);
Alert (newdate.tolocaledatestring ())//plus two months.
Newdate = DateAdd ("M", 2,now); Alert (newdate.tolocaledatestring ())//plus one year newdate = DateadD ("Y", 1,now); Alert (newdate.tolocaledatestring ()) </script>
The above is the entire contents of this article, I hope you can enjoy.