add of Date, Methods Webix Docs

adds the number of date units to a date

Date add(Date date,number inc,string mode, [boolean copy] );

Datea date object inc
numbera positive or negative number of units to be added to a date mode
stringthe name of a unit: "day", "week", "month", "quarter", "year", "hour" or "minute" copybooleandefines whether a copy of the date will be created

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