ButlerBlog

chad butler's weblog

  • About
  • Blog
  • WordPress Plugins
  • Contact

Date-O-Matic Javascript Day/Date Display

By Chad Butler Leave a Comment

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.

To use it, place the following in the of your html document:


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!

  • Facebook
  • Twitter
  • Email
  • Print
  • More
  • LinkedIn
  • Reddit
  • Tumblr
  • Pocket
  • Pinterest

Filed Under: Web Tagged With: javascript, tools, Web, webdev

Join Us!

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

Recent Posts:

  • Rediscover Your Brand Story: 7 Tips for Refreshing Your Company Identity
  • Creating Engaging Content: Tips for a Successful Content Marketing Strategy
  • After a Layoff or Underemployment: Ingenious Ways to Make Extra Money
  • Essential Tips for Freelancers Applying for a Mortgage
  • 5 Steps to Crafting Your Market Research Strategy
  • Revolutionizing Your Content Strategy: How AI Can Improve Your Content Marketing Efforts
  • Leveraging Content Marketing to Give Your Small Business an Edge in Today’s Digital Marketplace
  • Simple Tactics for Protecting Your Small Business Against a Recession
  • Create and delete WordPress sites in XAMPP with a simple batch file
  • Proofy.io Email Validation

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-2023 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.