Full Text Date
Never Trust a Tip Over 30!
Once again, we're working on a requested script here. A reader wanted to post a date that goes beyond the basic number returns. He wanted the date to display in text. I am the author of the script below. I wrote it to present the day and the month in text.
Here are the goods:
Each array starts with a line that announces to the browser that an array is starting. That line looks like this:
DaysofWeek = new Array()
The format is similar to setting up a new Date(), which we'll actually do later. The line announces a new Array() and gives the array a name. In this case the name is DaysofWeek. I made the name up just like I would a variable name, because in reality it is a variable name. It's just that this variable has multiple values.
The getDay() method returns the day of the week only it returns that day as a numeric value, zero through 6 representing Sunday through Saturday. Now do you see the reason for the order of days? We've set up an array of days that is equal to the returns that getDay() will return. A little later we'll get into why this is important.
Now that you're somewhat familiar with the format of an array, let's take a look at the second one. This one deals with the months of the year:
OK, now you're up to speed with the concept and structure of an array. We can begin calling for the array index through the getDay() and getMonth() methods.
Next Time: Pulling Out Part of the Array