How do I add one week to a date?

I’m pretty sure the setDate method of Date accepts any integer input in any browser and changes the date appropriately.


var testDate = new Date();
testDate.setDate(testDate.getDate() + 7);

But some references don’t specify this behaviour in documentation (some saying input is range of 1-31), so don’t know if every browser definitely does.

You can always go by the milliseconds route, as this will work across the board:


var testDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
testDate.setTime(testDate.getTime() + weekInMilliseconds);