This is a very simple date script that I wrote years ago. I have used it in some form or another on just about every site that I have worked on. It is a nice, simple, client-side javascript to display the day and the date.
//Date-O-Matic script - very simple date script //freeware date javascript //by: Chad Butler - https://butlerblog.com //please leave credit intact function dateomatic() { d = new Array(); d[0] = "Sunday"; d[1] = "Monday"; d[2] = "Tuesday"; d[3] = "Wednesday"; d[4] = "Thursday"; d[5] = "Friday"; d[6] = "Saturday"; m = new Array(); m[0] = "January"; m[1] = "February"; m[2] = "March"; m[3] = "April"; m[4] = "May"; m[5] = "June"; m[6] = "July"; m[7] = "August"; m[8] = "September"; m[9] = "October"; m[10] = "November"; m[11] = "December"; today = new Date(); document.write(d[today.getDay()]+", "); document.write(m[today.getMonth()]+" "); document.write(today.getDate()+", "); document.write(""+today.getFullYear()); }In the location that you want the date to display, place the following:
This will output the date. You can apply CSS to the output as necessary, or, for those lacking the necessary skills, you could wrap this with a (yuck!)
tag.
Obviously (or maybe not so obvious), there are a number of changes one could make based on desired output. For example, the days or months could be abbreviated in the script if you wanted “Thurs, Jan 12, 2006”. Or, the more savvy could change it to an output of “Thursday – 1/12/2006” by changing the month names to appropriate numbers and then changing the document.write section to:
document.write(d[today.getDay()]+" - ");
document.write(m[today.getMonth()]+"/");
document.write(today.getDate()+"/");
document.write(""+today.getFullYear());
Or, if you need scientific or European dating, switch the date and the month lines to get this:
document.write(d[today.getDay()]+" - ");
document.write(today.getDate()+"/");
document.write(m[today.getMonth()]+"/");
document.write(""+today.getFullYear());
If you are an old javascript hack, you probably had all that figured out (or already wrote your own), but if you are a js noob, tinkering with the output and maybe adding or subtracting from it, is a good way to “get under the hood” so-to-speak and learn how to use javascript.
Have fun!