Home arrow JavaScript arrow Using the Date() Object to Create a Clock

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 / 11
September 10, 2007
  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

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

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


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