Create the Clock

Now we need to start building the clock using the actual time.

provided by: 
Originally published at Internet.com


Scripper...

Now that we understand the offset and can actually pick out time zones, it's time to build the clock. That's done by the checkDateTime() function.

The Script's Effect

-----------------------------------

Here's the Code

This is a rather large function, so let's take it in chunks. The author has been nice enough to set apart each section and explain what it's for. We'll start up top and set the variables to juggle for the rest of the script:

function checkDateTime () { adjust=0 var today = new Date(); var year = today.getFullYear(); var month = today.getMonth()+1; var date = today.getDate(); var day = today.getDay(); var hour = today.getHours(); var minute = today.getMinutes(); var second = today.getSeconds();

The variable "adjust" is given the value of zero. Keep that in your brain. It'll come again at the very end of the tip.

Just like the previous script, this one starts by setting up the JavaScript method "Date()" and assigning the variable name "today". Now we set about plucking out just the elements we want from "Date()".

The script uses the "getFullYear()" method to return a four digit year. It's a good idea. The year is not manipulated in any way; it's just a display, so that will do just fine. The variable "year" is assigned the value...

Read article at Internet.com site

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML