HTML and CSS Reference
In-Depth Information
9.4 The Date Object
JavaScript provides the Date object for manipulating date and time. 2 Like the String and
Array objects, you can create as many instances as you like.
As we'll see, the Date object provides a number of methods for getting or setting spe-
cific information about the date and time. The date is based on the UNIX date starting
at January 1, 1970 (in Greenwich Mean Time 3 [GMT]), and doesn't support dates before
that time. Figure 9.19 gives you an idea of the difference between GMT and local time.
Time is measured in milliseconds (one millisecond is one thousandth of a second).
Because client-side JavaScript programs run on a browser, the Date object returns times
and dates that are local to the browser, not the server. Of course, if the computer is not
set to the correct time, then the Date object won't produce the expected results. Figure
9.20 shows a typical date and time control panel.
Figure 9.19 24-hour world time zones map with current time. Courtesy of .
2. For more information about the time and date, see
3. Greenwich Mean Time (GMT) is now called Universal Coordinate Time (UTC). The current time in
Greenwich, England is five hours + New York's present time, or eight hours + San Francisco's present
Search WWH ::

Custom Search