Ken Ward's Java Script Tutorial ...

JavaScript time ...

the months

Hello. Today is:

And the time is now (according to your computer):


  As promised, there is little new to learn to get the months. There is a function getMonth() which which corresponds with getDay(), and as with the days, we need to make an array writing the months in the way we want them displayed.

var myMonths=new Array(

"January","February","March","April","May","June","July","August",

"September","October","November","December");

And as with the days, we can display the month as follows:

var myMonths=new Array(

"January","February","March","April","May","June","July","August",

"September","October","November","December");

today=new Date()

thisMonth=today.getMonth()

document.write(myMonths[thisMonth])

Because this month is then the above code will result in !

However, we might not want this month, and prefer one, say, 3 months on - which is

For example, our next appointment will be in 3 months time, which is .

The code which achieves the above effects is shown below.

[an error occurred while processing this directive]