SHARE
Facebook X Pinterest WhatsApp

So, You Want A JavaScript Clock, Huh?

Written By
thumbnail
Joe Burns
Joe Burns
Jan 4, 2005

     A clock on your home page? Why, yes! I’ll have one too, please. The thing at the top center of the page is what you can get here. It’s a little JavaScript (not an applet) that loads into your browser, reads the time and then displays it. Pretty slick, eh? Please note that the script reads the time the browser is keeping; the time will be right in all time zones providing the viewer has his/her computer configured to give the correct time.

How To Do It…

     Oh, this one is so easy to do. First off, you need the script. I have it available to you as a simple text document. Remember, when you copy the script to copy it as is and in full. Do not attempt to change its wording or its format. Changing items to make them closer together kills the script and forbids it from working. Just copy it straightaway or save it for later. You’ll notice toward the bottom of the text page that there is a </SCRIPT> command and then a small form program. Get that, too. It gives you the box that goes around the clock.


Click here to get it. (If you’re using IE, click View, Source for the text.)

Is That It?

     Yeah. That’s it. Just paste this pup where you want it to go on the page. If you’ve read over my other two JavaScript tutorials, this one will seem like a breath of fresh air. There’s no changing the text or placing commands that make the script react. Just place it as if it was all one command and POOF, you get a clock.

     Oh, how I wish it was harder than that. How I love to make you suffer…

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.