Possible Duplicate:
How to add number of days to today’s date?
I would like to add X days , where X is the number I specified earlier, to the certain date.
Eg. the date is the 29/11/2012
(format: DD/MM/YYYY
), and I would like to add 5
days to this date so the output should be 03/12/2012
.
What have I tried:
var days_to_add = 5;
$myyear = 2012;
$mymonth = 11;
$myday = 29;
date = new Date();
date.setFullYear($myyear,$mymonth,$myday);
date.setDate(date.getDate()+(days_to_add-1));
alert(date.getDate()+'/'+date.getMonth()+'/'+date.getFullYear());
It is working, but only when the date doesnt pass to the next month of a given date, otherwise, the output is good.
Have you guys any solutions for that?