script that displays date 10 days in future

S

stef25

im using the script below to display todays date. Could someone tell me
how to alter this script so that is displays the date 10 days in the
future? So, if its 01-Jan-06 today, it should actually display
10-Jan-06. Thanks ...

function getDateString(oDate)
{
// Use today as default value.
if (oDate == null)
oDate = new Date();

var m = oDate.getMonth() + 1;
var d = oDate.getDate();

if (m < 10)
m = "0" + m;

if (d < 10)
d = "0" + d;

// ISO 8601 date (YYYY-MM-DD).
return oDate.getFullYear() + "-" + m + "-" + d;
}
 
E

ermouth

it can be smth like this:

var dtToday = new Date();
var iMillisecondsPerDay = 24*60*60*1000;
var dtTenDaysAfter = new Date(dtToday .valueOf()+10*iMillisecondsPerDay);
var sTenDaysAfter = getDateString (dtTenDaysAfter);

voila :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top