Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need date script

Status
Not open for further replies.

flasher

Technical User
Mar 4, 2002
245
US
Hi, I'm looking for a script that will always display the last day of the current month. So this month it should say September 30 and next month it should read October 31... Any leads?? Thank you!
 
try this:

Code:
		<script type=&quot;text/javascript&quot;>
			var now = new Date();
			var leap = (parseInt(now.getFullYear(), 10) % 4 == 0);
			var arMonths = [&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;,
				&quot;June&quot;, &quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot;];
			var arDays = [31, (leap?29:29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
			var result = arMonths[now.getMonth()] + &quot; &quot; + arDays[ now.getMonth() ];
			alert(result);
		</script>


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top