Javascript Reserved Words


The Date () Object


METHOD
RETURNS ATOMIC VALUE

getDate()
Day of the month

getDay()
Day of the week (Sunday = 0)

getFullYear()
Year as four digits

getHours()
Hours 1-23

getMilliseconds()
Milliseconds

getMinutes()
Minutes

getMonth()
Month number, 0=January

getSeconds()
Seconds

getTime()
Millisecs from the Unix epoch

METHOD
RETURNS STRING

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:

  1. ATOMIC VALUES: var today = new Date (year, month (0-11), day (1-31), [optional, default 00:00:00] hour (0-23), minutes, seconds, milliseconds);
  2. TIMESTAMP: var today = new Date (86,400 * number of days);
  3. 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.