programming-examples/js/Date/Write a JavaScript function to add specified weeks to a date..js
2019-11-15 12:59:38 +01:00

11 lines
256 B
JavaScript

function add_weeks(dt, n)
{
return new Date(dt.setDate(dt.getDate() + (n * 7)));
}
dt = new Date();
console.log(add_weeks(dt, 10).toString());
dt = new Date(2014,10,2);
console.log(add_weeks(dt, 10).toString());