SunQuest
 
       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  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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

    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway