• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Date Methods

Because you'll often need to deal with dates, here's a table of all of the methods of the Date object. In Table 8.1, you'll see a reference to UTC, which stands for Coordinated Universal Time, which replaced Greenwich Mean Time (GMT) as the world standard for time in 1986. Any of the methods that contain UTC are available only in JavaScript 1.2 or later.

Table 8.1. Date Methods
Method Description Returned values Supporting Browsers
getDate() getUTCDate() The day of the month1–31JavaScript 1.0 JavaScript 1.2
getDay() getUTCDay() The integer value of the day of the week0–6JavaScript 1.0 JavaScript 1.2
getFullYear() getUTCFullYear() The full four digit year1900 +JavaScript 1.2
getHours() getUTCHours() The integer hour of the day0–23JavaScript 1.0 JavaScript 1.2
getMilliseconds() getUTCMilliseconds() The number of milliseconds since the last second0–999JavaScript 1.2
getMinutes() getUTCMinutes() The number of minutes since the last hour0–59JavaScript 1.0 JavaScript 1.2
getMonth() getUTCMonth() The month of the year0–11JavaScript 1.0 JavaScript 1.2
getSeconds() getUTCSeconds() The number of seconds since the last minute0–59JavaScript 1.0 JavaScript 1.2
getTime() Number of milliseconds since midnight 1 January 1970 JavaScript 1.0
getTimezoneOffset() Difference between local time and GMT in minutes.0–1439JavaScript 1.0
getYear() The year field of the date0–99for the years 1900–1999, four digit year thereafterJavaScript 1.0
parse() Given a date/time string, return the number of milliseconds since midnight 1 January 1970 JavaScript 1.0
setDate() setUTCDate() Set the day, given a number between 1–31Date in milliseconds (as of JavaScript 1.2)JavaScript 1.0 JavaScript 1.2
setFullYear() setUTCFullYear() Set the year, given a four digit yearDate in millisecondsJavaScript 1.2
setHours() setUTCHours() Set the hour, given a number between 0–23Date in milliseconds (as of JavaScript 1.2)JavaScript 1.0 JavaScript 1.2
setMilliseconds() setUTCMilliseconds() Set the milliseconds, given a numberDate in milliseconds between 0–999JavaScript 1.2
setMinutes() setUTCMinutes() Set the minutes, given a number between 0–59Date in milliseconds (as of JavaScript 1.2)JavaScript 1.0 JavaScript 1.2
setMonth() setUTCMonth() Set the month, given a number between 0–11Date in milliseconds (as of JavaScript 1.2)JavaScript 1.0 JavaScript 1.2
setSeconds() setUTCSeconds() Set the seconds, given a number between 0–59Date in milliseconds (as of JavaScript 1.2)JavaScript 1.0 JavaScript 1.2
setTime() Set a date, given the number of milliseconds since 1 January 1970Date in millisecondsJavaScript 1.0
setYear() Set the year, given either a two or four digit valueDate in milliseconds (as of JavaScript 1.2)JavaScript 1.0
toGMTString() toUTCString() The GMT date and time in string formatday dd mmm yyyy hh: mm:ss GMTJavaScript 1.0 JavaScript 1.2
toLocaleString() The local date and time in string formatVaries based on OS, locale, and browserJavaScript 1.0
toString() The local date and time in string formatVaries based on OS and browserJavaScript 1.0
UTC() Given a date in year, month, day (and optional hours, minutes, seconds, and milliseconds) format, return the numberDate in milliseconds of milliseconds since 1 January 1970JavaScript 1.0
valueOf() Number of milliseconds since midnight 1 January 1970Date in millisecondsJavaScript 1.2



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint