In comp.lang.javascript message <a1b603ad-f021-4c69-b0ee-57b25e0dd3ae@27
g2000hsf.googlegroups.com>, Thu, 29 May 2008 20:43:48, sixstringsk
<th****************@yahoo.composted:
>Can anyone here help me with this...
I have a date code to display the date 7 days in the future— check it
out here : http://hidefsounds.com/date.html
The problem is that the day of the month doesn't reset when it's past
30/31 days... So currently it shows:
"May 36, 2008."
Any help would be appreciated. Thanks in advance.
Code which is that short should be posted to the newsgroup, for easier
handling.
<QUOTE>
<script language="JavaScript1.2">
// ^^^^^^^^^^^^^^^ Deprecated.
// text/javascript preferred, or nothing.
<!-- Begin
// superfluous
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
// var months = ["January", ... "December"] better, and zero-based
var time=new Date();
var lmonth=months[time.getMonth() + 1];
// then no need to add 1
var date=time.getDate() +7;
var year=time.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; //
http://onyx.idbsu.edu/~ipowell
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - cannot find
// time.getFullYear() is better
document.write("" + lmonth + " ");
// ^^^^ superfluous
document.write(date + ", " + year + "");
// End -->
// superfluous
</script>
</QUOTE>
Obviously the month will over-range, as you have done nothing to make it
do otherwise.
You should follow Lasse's advice, but ignore the erroneous signature.
Otherwise
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.