topical media & game development
basic-javascript-04-ch4-examp6.htm / htm
<html>
<body>
<script language="JavaScript" type="text/javascript">
var months = new Array("January","February","March","April","May","June","July",
"August","September","October","November","December");
var dateNow = new Date();
var yearNow = dateNow.getFullYear();
var monthNow = months[dateNow.getMonth()];
var dayNow = dateNow.getDate();
var daySuffix;
switch (dayNow)
{
case 1:
case 21:
case 31:
daySuffix = "st";
break;
case 2:
case 22:
daySuffix = "nd";
break;
case 3:
case 23:
daySuffix = "rd";
break;
default:
daySuffix = "th";
break;
}
document.write("It is the " + dayNow + daySuffix + " day ");
document.write("in the month of " + monthNow);
document.write(" in the year " + yearNow);
</script>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.