Home arrow JavaScript arrow 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
(Page 1 of 4 )

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.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- 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
- Dynamic jQuery Styling

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 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials