add

adds the number of date units to a date

Date add(Date date,number inc,string mode, [boolean copy] );
dateDatea date object
incnumbera positive or negative number of units to be added to a date
modestringthe name of a unit: "day", "week", "month", "quarter", "year", "hour" or "minute"
copybooleandefines whether a copy of the date will be created
Datea date object

Example

var date1 = new Date(2012,11,12);
// the copy parameter is set to false, the date won't be copied
// so the date passed as a 1st parameter will be modified
var date2 = webix.Date.add(date1,2,"day");
 
console.log(date1); // -> Fri Dec 14 2012 00:00:00 GMT+0300 
console.log(date2); // -> Fri Dec 14 2012 00:00:00 GMT+0300 
 
var date1 = new Date(2012,11,12);
// the copy parameter is set to true, the date will be copied
// so the date passed as a 1st parameter won't be modified
var date2 = webix.Date.add(date1,2,"day",true);
 
console.log(date1); // -> Wed Dec 12 2012 00:00:00 GMT+0300 
console.log(date2); // -> Fri Dec 14 2012 00:00:00 GMT+0300

Back to top