View Full Version : Need help adding no. of days to specific date

07-14-2004, 07:01 AM
hello there,
I am facing a problem with add no. of days to date,
All the material that I found on the internet is concern with the current date whlie I want to calculate reultant date value after adding no. of days to any given date(not current).

I am using this script:
<script language="JavaScript"><!--
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);

alert(addDays(new Date(),10));

but the problem is the script add no. of days to current date,
I will really apreciate any help ,
thank you

07-14-2004, 07:12 AM
Using your original function, you can pass a date other than the current date:

alert(addDays(new Date("7/16/2004"),10));
alert(addDays(new Date(2004, 8, 17),10));

But your function can be simplified like this:

function addDays(myDate, days){
return myDate;