The mystery of time ...

clocks and dates

JavaScript has a number of functions that deal with time. In fact, it has an object
called Date(). If I want to create a new date, then I can use this object.

Once we have created a date object for ourselves we can do some things with it. But
first we must create the object.

For example:

myDate=new Date("25 December, 2000")

document.write(myDate);

// result Mon Dec 25 00:00:00 UTC 2000

// According to IE4

You must write the date exactly in the above format - spaces, quotes and all. You can
also add a time:

myDate=new Date("25 December, 2000 12:00:00")

document.write("<br>"+myDate)

// result Mon Dec 25 12:00:00 UTC 2000

You can write the date in these ways too:

myDate=new Date(2000,11,25)

document.write(myDate);

// result Mon Dec 25 00:00:00 UTC 2000

myDate=new Date(2000,11,25,12)

document.write("<br>"+myDate)

// result Mon Dec 25 12:00:00 UTC 2000

Did you notice something funny? December is normally the 12th month, isn't it? But you
will NOT be surprised to find that for the computer the months start at zero and end with
11!

So 0 is January and 11 is December, when we are talking JavaScript.

You will also discover that the days, too, begin at zero. So, Sunday is zero and
Saturday is 6!

Now we have learned about the Date object, we can explore what we can do with it.

The jsEditor contains many examples of the functions related to TIME. You can order the jsEditor onlineand
download the full version immediately, so in a few minutes you
could be using it to help you learn and develop scripts.