Home arrow JavaScript arrow Page 2 - Using the Date() Object to Create a Clock
JAVASCRIPT

Using the Date() Object to Create a Clock


Since the idea of a date and time being a convenient display for computer users was someone's brainchild, programmers have been at the end of their tether trying to standardize it for operating systems like Windows. Apart from the many time zones, it seems that the way in which the date and time are displayed can be enough to irritate a user. In this article you'll learn how to do it without too much trouble thanks to the date() object.

Author Info:
By: Stephen Davies
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
September 10, 2007
TABLE OF CONTENTS:
  1. · Using the Date() Object to Create a Clock
  2. · So, what is the time?
  3. · A Live Clock Example
  4. · A Useful Date Format Example

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using the Date() Object to Create a Clock - So, what is the time?
(Page 2 of 4 )

Two other aspects that should be noted here are the Date object's ability to display UTC or Coordinated Universal Time and also GMT or Greenwich Mean Time. This UTC value is measured in milliseconds since January 1, 1970, from midnight. This behavior exists on all OS platforms and is therefore universally accepted through the JavaScript code. Where the year is concerned, getFullYear() assists with the correct format by using four digits to avoid dates before 2000 becoming inaccurate. The year 1997 would need to be entered as 1997 and not 97, which uses only the last two digits. 

Another point to note here is what happens during the interpretation by JavaScript. Bear in mind that 280 seconds is interpreted as 4 minutes and 40 seconds. The Macromedia flash player and other applications all utilize the Date object's properties to extract the time and date from the operating system, whether it is a MAC or Windows platform. There are a couple of slight differences here between the operating systems on a MAC and a PC. There is the absence of a time zone database on MAC OS systems 8 and 9, so DST or Daylight Saving Time is not reported correctly. This has been corrected on MAC OS X systems. On Windows systems on PCs, the DST adjustment is made automatically.

Why is it that the human psyche is so obsessed with time anyway, causing programmers to have to cater to this need? It is good for web sites that the Date object was created. People spend so much time on their computers these days, whether it is for work purposes or just pure recreation. Being date and time conscious helps one realize what time it is on a regular basis. It is always there in the bottom right corner in the systems tray on Windows OS systems.

Now, on web pages, it has become ubiquitous as more and more designers want to utilize the Date object to let their visitors know the time. Days can be complex. A meeting may be scheduled; a birthday needs to be planned; is it time to leave work yet and go home and relax? Of course, it cannot be forgotten how important it is not to miss an episode of "Lost" or "24" due to being plugged into the computer monitor. The Date object applies to our constant need for information throughout the day.

There are other methods that utilize the Date() object, but for this article, a walk through of how to manipulate the object to produce some clock and date formats will be explored.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials