JavaScript
  Home arrow JavaScript arrow 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


    (Page 1 of 4 )

    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.

    Date Object Methods

    It seems that most people want to be conscious of the date and time. There is almost an obsession to it that needs to be satisfied. So it was no surprise when operating systems began to display the time on the user's desktop so they do not miss their favorite TV show while killing time on the computer.

    The Date() object is a great JavaScript function for manipulating the date and time to suit any particular format. JavaScript users can quickly create functions for usage in a variety of methods. Here is an instance example:

    dateToday = new Date()

    The instance dateToday now can access all the methods within the Date() object. The methods within the Date() object read the data from the PC - year, month, day, hour, minutes and seconds. There are many methods that can be used by the JavaScript coder to extract the required data. The most common ones seem to be:

    getDate() - day of the month
    getDay() - day of the week
    getHours() - the hours
    getMinutes() - the minutes
    getSeconds() - the seconds
    getMonth() - the month
    getFullYear() - the four digit year

    Then there is the ability to assign values:

    setDay() - set the day
    setHours() - set the hours
    setMinutes() - set the minutes
    setSeconds() - set the seconds
    setMonth() - set the month
    setFullYear() - set the 4 digit year

    There are a host of other functions. For this article and its purpose, this will help the coder wanting to come to grips with the Date() object.

    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 4 Hosted by Hostway
    Stay green...Green IT