There are many different date formats. Some consist only of numbers (e.g., 31/12/97), while others include real month names (e.g., December 31, 1997). There are many distinct date formats. In this section we'll show you how to display the date in a Month Day, Year format. This convention is usually better than a "number-only" one, due to the fact that different countries have different ways of writing the date in a "number-only" format. For example, the last day of the millenium could be written in one of the following ways:
- 31/12/99 (in Israel, for example)
- 12/31/99 (in the US, for example)
What does 9/10/97 stand for? September 10, or October 9? It depends on where you live. The following script prints the current date in a Month Day, Year format.
makeArray() function is a user-defined constructor. It accepts a list of values (arguments) and puts them in an array. You could use the built-in
Array() constructor instead, but it isn't supported by Navigator 2.0x.
getString() function accepts a date, and returns a string in the Month Day, Year format. For example, it might return
"May 5, 1980". The third global statment in the script assigns that string to a variable named
str, and then prints it.
If you would like to display the date somewhere in an HTML table, you're in trouble. Never embed a script in a table, especially if it has a
Created: September 11, 1997
Revised: April 7, 1998