Solutions UMUC Logo

http://polaris.umuc.edu/~flazarus/



Included on this page are two aproaches to time stamping using mm/dd/yy. The first is quite elegant, the second more versitile. It is interesting to note that the Netscape and Microsoft browsers handle the first script quite differently. No mm/dd/yy for Netscape.

A very elegant but perhaps a less versatile date/time script

<!-- Inline style sheet construct to set the typeface. -->
<P STYLE="font: 14pt Comic Sans MS; color: blue;">

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
var d = new Date().toLocaleString().slice(0,27);
document.write(d);
//-->
</SCRIPT>
<!-- Style closure>
</P>
Produces:

More versitile

<!-- Inline style sheet construct to set the typeface. -->
<P STYLE="font: 14pt Comic Sans MS; color: blue;">

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!-- Engage Cloaking Device

var dateIs=new Date();
var dayNumber=new Array("01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20","21","22","23","24","25",
"26","27","28","29","30","31");
var monthNumber=new Array("01","02","03","04","05","06","07","08","09","10",
"11","12");
var theDay= dateIs.getDate();
var theMonth = dateIs.getMonth();
var theYear = dateIs.getFullYear();
document.write("Today's date is " +
monthNumber[theMonth]+"/"+dayNumber[theDay - 1]+"/"+theYear);

// Drop Cloak -->

</SCRIPT>
<!-- Style closure>
</P>
Produces:


Return to Solutions Index