4.8 DATE OBJECT
A Date is an object in JavaScript. An instance is created using the Date() object.
var myDt = new Date(); //returns current date
//defined in the local machine
var myDt = new Date(1926, 10, 23); //pass date in the order—
//year, month (0-11), day
Note that the month follows 0–11 rather than 1–12 convention. The time is optional. If it is required, pass additional parameters for hour, minutes, seconds and milliseconds.
Fig. 4.14 Date display
The Date object has several get and set methods for getting and setting date components. The following is a list.
- d.getFullYear
- d.getMonth—returns an index between 0 and 11
- d.getHour ...
Get Web Technology: Theory and Practice now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.