ButlerBlog

chad butler's weblog

  • About
  • Blog
  • WordPress Plugins
  • Contact

Date-O-Matic

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!

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print
  • More
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Pinterest (Opens in new window) Pinterest

Join Us!

I will never share your information. No spam. No junk. No kidding. Unsubscribe anytime.

Recent Posts:

  • The High Price of Free Plugins
  • YouTube Success: Key Tips for Enhancing Video Optimization and Visibility
  • Mobile App vs. Mobile Website Ideal Choice for your Business
  • Top Strategies to Boost Your Brand’s Visibility and Impact
  • Advanced Blogging Strategies: Using Analytics, A/B Testing, and Conversion Optimization Techniques to Grow Your Audience
  • Unlock Real-Time Process Insights to Save Time and Money
  • How Writers Can Attract More Audience Attention
  • Dress for Success – Even at Home
  • Mastering the Art of Crafting SMART Marketing Goals
  • Rediscover Your Brand Story: 7 Tips for Refreshing Your Company Identity

Archives

  • About
  • Blog
  • Archive
  • Contact

Site powered by WordPress, running on the Genesis Framework from StudioPress.

Unless otherwise noted, content on this site is © 2006-2025 ButlerBlog and may not be reproduced without express written permission from the author.

Some content may include affiliate links for which this site receives a small commission.