In an array, the first element is zero, so "Sunday" is zero ... which
ties in with JavaScript very nicely indeed!

So myDays[2], for example, is "Tueday".

The jsEditor can create arrays from a list of elements. This can be a great time saver,
and so you can make large arrays easily. 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. You will also be supporting this
site.

We can get today's day as follows:

today=new Date()

thisDay=today.getDay()

thisDay=myDays[thisDay]

document.write(thisDay)

The result is which is today!

So we can use JavaScript's Date() object along with getDay() to find the number, in
JavaScript speak, of the day and then use the array of days we have created to get the
human name of the day.

This is much easier than teaching people to say, "See you on 3, then".
"No, I'm busy on 3, can we make it 5?" When they are busy on Wednesday but can
make Friday!

Consider the following example:

Enter a date (use the same format as the example):

Day of week appears here

In this case, we use a Date object with the date 25 December, 2000. (The format is
important). In the same way as before, we get the day (getDay()) for this particular date.
If you enter another date, then you can find out which day that is. When you click on the
button, the following code activates:

inputtype="button"value="Get day of week"onclick="getTheDay(this.form.textDate)" />

<

small>

Day of week appears here

<

/small>

<

br />

<

inputtype="text"name="textDay" VALUE size="25"maxlength="25" />

<

br />

<

/form>

The only thing new here is the use of eval():

myDate=new Date(eval('"'+aText.value+'"'))

We need the date with quotes around it, but, as it appears in the box, it does not have
any. So we add the quotes. But this makes a mere string, and we want a Date object. So we
use eval() to make the changes.

So, using the Date object in JavaScript, with getDay() we can get the day of the week
for any date supported by JavaScript.

Now we know how to extract the days from a date, we will find extracting the Months
much easier.