An Explanation of the Script
If you click on the screen shots below, you can see the simple script I wrote and the results that appear in a browser, Mozilla Firefox in this case. The script is operational; however, since it’s for demonstration purposes, I used the simple opening and closing HTML tags ( and ); you don’t want to be so careless with live web pages. Take the time to declare a document type such as strict or transitional.
I then declared and initialized arrays to hold the names of the months and the names of the days of the week; I abbreviated them, but you don’t have to. Notice that this is all done in the head of the document, not the body. We’re now ready to print the date using document.write. The methods used in this script are getDate which returns the date’s day of the month, getDay which returns the day of the week, getMonth for the return of the month, and getFullYear which returns a full four digit year. There are a good number of other methods you might want to use; but, these are the ones needed for this script. Finally, we have the closing of the CDATA section and the closing script tag.