I have created a JSFiddle for this, here the link http://jsfiddle.net/8mad9/
If you want to just add 14 days (considering weekends), that's pretty straightforward.
var today = new Date();
var days = 14;
var deliveryDate = new Date(today.getTime() + (days * 24 * 60 * 60 * 1000));
console.log(deliveryDate);
if today is "Sun Jan 05 2014 16:45:44", will print out "Sun Jan 19 2014 16:46:56".
If we don't want to consider weekends we need to calculate add the weekend days.
For example, today is the 5th of Jan 2014, Sunday.
console.log(new Date().getDay());
--> 0
Sunday is 0, Monday is 1.... and Saturday is 6
Using this, we can use a loop to calculate the 14 business days in this way
var today = new Date(); //5th jan 2014
var business_days = 14;
var deliveryDate = today; //will be incremented by the for loop
var total_days = business_days; //will be used by the for loop
for(var days=1; days <= total_days; days++) {
deliveryDate = new Date(today.getTime() + (days *24*60*60*1000));
if(deliveryDate.getDay() == 0 || deliveryDate.getDay() == 6) {
//it's a weekend day so we increase the total_days of 1
total_days++
}
}
console.log(today);
console.log(deliveryDate);
--> Sun Jan 05 2014 17:13:39 GMT+0100 (CET)
--> Thu Jan 23 2014 17:13:39 GMT+0100 (CET)