Remember that because a date is an object, you must specify
new when you create it, otherwise errors will inevitably result.
An acceptable example is:
luckyDay = new Date(2000, 9, 13);
alert("Your lucky day is " + luckyDay);
A quick question - what day does the above represent? Full marks if
a bit far and certainly sows a lot of confusion by counting months
from zero as well! Note that if you say luckyDay.value you're out of
luck - you'll get an undefined for your troubles!
There are lots. Here they are:
||What it does
||What year is it?
||get day of month (getDay gives you the day of the week)!
|getHours, getMinutes, getSeconds
||As you would expect..
||Snip out the time section
||What is the time zone offset for this region (in minutes)
|setYear*, setMonth, setDate, setHours, setMinutes, setSeconds
||all take an integer and set the appropriate part of the date,
for example, setHours(11)
||set Time of date object
||convert date to Greenwich mean time format
||convert date to the format commonly used in the user's
||How many milliseconds have elapsed since midnight 1970-1-1 GMT?
Redundant (and similar) is parse() which returns the number
of milliseconds since midnight 1970-1-1 local time.
|Items marked with a red asterisk*
are now 'deprecated' - you use them at your own risk.|
Needless to say, grown up date handling (conversion to and
from Julian dates, and adding or subtracting a certain number of days)
are conspicuously absent. You have to add your own.
As is usually the case with computer languages, the designers have
done everything in their power to sow confusion. Let's just