Created: June 1998; modified: August 1999; Updated October 2002

JavaScript Date Formatting Demo

<script language="JavaScript" type="text/javascript">
<!--
function makeArray() {
     for (i = 0; i<makeArray.arguments.length; i++)
         this[i] = makeArray.arguments[i];
 }
 
function getFullYear(d) {
    var y = d.getYear();
    if (y < 1000) {y += 1900};
    return y;
}

var days = new makeArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var months = new makeArray("January","February","March","April","May","June","July","August","September","October","November","December");

function format_time(t) {
   var Day = t.getDay();
   var Date = t.getDate();
   var Month = t.getMonth();
   var Year = getFullYear(t);
   timeString = "";
   timeString += days[Day];
   timeString += " ";
   timeString += months[Month];
   timeString += " ";
   timeString += Date;
   timeString += ", ";
   timeString += Year;
   return timeString;
}
// -->
</script> 


<script language="JavaScript">
<!--
m = new Date(document.lastModified);
d = new Date();
document.write("The normal <I>document.lastModified\</i> string: "+m+"<br>");
document.write("The modification date after formatting: "+format_time(m)+"<p>");
// -->
</script>