HTML and CSS Reference
EXAMPLE 9.17 ( CONTINUED )
document.write("The full year is " + year +"<br />");
document.write("<b>The time is:</b> " +
hours + ":" + minutes + ":" + seconds );
A new Date object called now is created. It contains a string with the current date
and time: Mon Aug 10 18:22:36 GMT-0700(Pacific Daylight Time).
The variable called hours is assigned the return value of the getHours() method.
The variable called minutes is assigned the return value of the getMinutes() method.
The variable called seconds is assigned the return value of the getSeconds() method.
The variable called year is assigned the return value of the getFullYear() method,
2010 . The output is shown in Figure 9.21.
Figure 9.21 Date object and its methods.
perform, such as the number of days before a date, or between two dates, the informa-
tion in Table 9.4 might be helpful in converting milliseconds to minutes, hours, days,
and so forth.