[thelist] (javascript) changing date

Keith cache at dowebs.com
Sat Dec 1 17:27:49 CST 2001


Hi irina,

You are advancing the day only, you need to advance the Date 
instead, then everything else will fall into place. Javascript has a 
built-in calendar that extends for another couple of decades. If you 
roll to the proper date first all built-in date methods reference that 
future date. To roll everything forward 35 days into next month and 
next year make these changes;

today=new Date()
today.setDate(35)
day=today.getDate()

> year = today.getYear();
> if (year < 2000)    // Y2K Fix, Isaac Powell
> year = year + 1900; // http://onyx.idbsu.edu/~ipowell
> 
> end = "th";
> if (day==1 || day==21 || day==31) end="st";
> if (day==2 || day==22) end="nd";
> if (day==3 || day==23) end="rd";
> day+=end;
> 
> document.write("<font face=Arial size=2><b>");

document.write(d[today.getDay()]+", "+m[today.getMonth()]+" ");
document.write(day+", " + year);

> document.write("</font></b>");
> // End -->
> </script>


keith





More information about the thelist mailing list