How to add number of days to today's date?

Linda725 picture Linda725 · Sep 29, 2010 · Viewed 661.5k times · Source

I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery.

Answer

p.campbell picture p.campbell · Sep 29, 2010

You can use JavaScript, no jQuery required:

var someDate = new Date();
var numberOfDaysToAdd = 6;
someDate.setDate(someDate.getDate() + numberOfDaysToAdd); 

Formatting to dd/mm/yyyy :

var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();

var someFormattedDate = dd + '/'+ mm + '/'+ y;