View Single Post
Old 03-23-2007, 01:58 AM  
hjnet
Confirmed User
 
Join Date: May 2002
Location: European Union
Posts: 3,815
I honestly don't understand what exactly you're trying to do, but maybe this helps

Code:
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()

var daytemp=mydate.getDate()  // gets todays day
mydate.setDate(daytemp+9)     // adds 9 days and hopefully increments the month
var daym=mydate.getDate()     // gets new day

var month=mydate.getMonth()   // gets new month value, with 9 days added already
if (month<10)
month="0"+month

if (daym<10)
daym="0"+daym
document.write(""+month+"/"+daym+"/"+year+"")
I've not tested it, so it could be that there are some typos built in
And I'm sure there's a better solution to this than using the Date Class, there's for sure a Class that simply allows you to add a specific numer of days to a given date.

If you wanna test it with different dates you can also replace the first line with something like
Code:
var mydate=new Date(year, month, date) 

// year - the year minus 1900.
// month - the month between 0-11.
// date - the day of the month between 1-31.
hjnet is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote