JavaScript
  Home arrow JavaScript arrow Page 2 - Using the Date() Object to Create a Clock
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Using the Date() Object to Create a Clock
By: Stephen Davies
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-09-10

    Table of Contents:
  • Using the Date() Object to Create a Clock
  • So, what is the time?
  • A Live Clock Example
  • A Useful Date Format Example

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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.

    More JavaScript Articles
    More By Stephen Davies


       · Hi There,Thanks for the nice article about placing the date and time on my...
       · You are welcome. i will be posting more javascript articles on various useful...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT