The Date () Object
METHOD
RETURNS ATOMIC VALUE
getDate()
Day of the month
getDay()
Day of the week (Sunday = 0)
getFullYear()
Year as four digits
getMilliseconds()
Milliseconds
getMonth()
Month number, 0=January
getTime()
Millisecs from the Unix epoch
toLocaleString()
July 5, 2012 1:30:05 PM EDT
toLocaleDateString()
July 5, 2012
toLocaleTimeString()
1:30:05 PM EDT
toString()
Thu Jul 05 2012 13:30:05 GMT-0400 (EDT)
toDateString()
Thu Jul 05 2012
toTimeString()
13:30:05 GMT-0400 (EDT)
toISOString()
2012-07-05T17:30:05.000Z
toJSON()
2012-07-05T17:30:05.000Z
Three methods to set date:
- ATOMIC VALUES: var today = new Date (year, month (0-11), day (1-31), [optional, default 00:00:00] hour (0-23), minutes, seconds, milliseconds);
- TIMESTAMP: var today = new Date (86,400 * number of days);
- STRING: Need to watch syntax. a) July 5, 2012; b) 07/05/2012 with optional 13:30; c) Thu, 05 Jul 2012 13:30:00 GMT-0500.