Here you can find the source of add(interval, value)
Date.MILLI = 'ms'; Date.SECOND = 's'; Date.MINUTE = 'mi'; Date.HOUR = 'h'; Date.DAY = 'd'; Date.MONTH = 'mo'; Date.YEAR = 'y'; Date.prototype.add = function(interval, value){ var d = this.clone(); if (!interval || value === 0) return d; switch(interval.toLowerCase()){ case Date.MILLI:/*from www . j a v a 2s.c om*/ d.setMilliseconds(this.getMilliseconds() + value); break; case Date.SECOND: d.setSeconds(this.getSeconds() + value); break; case Date.MINUTE: d.setMinutes(this.getMinutes() + value); break; case Date.HOUR: d.setHours(this.getHours() + value); break; case Date.DAY: d.setDate(this.getDate() + value); break; case Date.MONTH: d.setMonth(this.getMonth() + value); break; case Date.YEAR: d.setFullYear(this.getFullYear() + value); break; } return d; }
Date.prototype.DateAdd = function(strInterval, Number) { var dtTmp = this; switch (strInterval) { case 's': return new Date(Date.parse(dtTmp) + (1000 * Number)); case 'n': return new Date(Date.parse(dtTmp) + (60000 * Number)); case 'h': return new Date(Date.parse(dtTmp) + (3600000 * Number)); ...
Date.prototype.add=function(amount,field){ if(amount){ switch (field) case "y": this.setFullYear(this.getFullYear() + amount); break; case "q": this.setMonth(this.getMonth() + amount * 3); ...
Date.prototype.add = function(thisMany) { var self = this; return { minutes: function() { var newDate = new Date(self); newDate.setMinutes(self.getMinutes() + thisMany); return newDate; }}; };
Number.prototype.addDate=function(num){ var date=this; var dates=[]; var d=new Date(Number(date).dateFormat()); d.setDate(d.getDate()+(num)); dates.push(d.getFullYear()); dates.push(Number(d.getMonth()+1).addZero()); dates.push(Number(d.getDate()).addZero()); var next_date=dates.join(""); ...
Date.prototype.addMilliseconds = function(value) this.setTime(this.getTime() + value); return this; };
Date.prototype.dateAdd = function (interval, number) { var d = new Date(this); var k = { 'y': 'FullYear', 'q': 'Month', 'm': 'Month', 'w': 'Date', 'd': 'Date', 'h': 'Hours', 'n': 'Minutes', 's': 'Seconds', 'ms': 'MilliSeconds' }; var n = { 'q': 3, 'w': 7 }; eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')'); return d;