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.