Scripting the Current Date With JavaScript

<!--// Hide from old browsers
var dayNames = new Array("Sunday","Monday","Tuesday",
var monthNames=new Array("January","February","March","April","May",
var now = newDate( );
document.write(dayNames[now.getDay()] + ", " + monthNames[now.getMonth()]
    + " " + now.getDate() + now.getYear());
// stop hiding -->

The script was placed into a table.
var dayNames=new Array() has each day of the week in quotes and separated with only a comma and no spaces.
var monthNames = new Array() is set up similarly.
Date() is a JavaScript built-in method. var now = new Date() refers to that built-in method. The method is passed to to the variable named now. document.write( ) is a JavaScript method; it is one of the first ones you will learn about if you have not already conquered this one. Everything between the parentheses can be written into the document if it is in quotation marks (single or double). The values of actual variables are not in quotes. document.write( ) is lower case. JavaScript is case-sensistive.

You have my permission to cut and paste this date script into your Web pages. Place it wherever you would like that date to appear. Code any formatting, if you wish, before the script and close formatting after the script.

The Date and Time Stamp

The following example is just a date and time stamp, if you want to stamp a document. It will not keep a current date and time, just the stamped date and stamped time like a permanent record.


But this line of code has to go into a regular JavaScript script where you want the date to appear. Again, code your formatting before and after the JavaScript script. It goes like this:

<!-- Hide from old browsers

The result is: 

E-mail us!
Updated 4 January 2013
All Rights Reserved