add

adds the number of date units to a date

object add(object date,number inc,string mode,boolean copy);

Parameters

dateobjecta date object
incnumbera positive or negative number of units to be added to a date
modestringthe name of a unit: "day", "week", "month", "year", "hour" or "minute"
copybooleandefines whether a copy of the date will be created

Returns

objecta 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