How do I add one week to a date?

Hi,
I am using the following to create a date

var the_date = new Date(dateText);

The date format I use is dd/mm/yyyy, is there a way to add 1 week to the date?

Thanks

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);