• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part: VII Appendixes > The Date Class

The Date Class

Table A.9. Methods of the Date Class
NameFormatDescription
Date.getDatemyDate.getDate()Returns the day of the month from 1 to 31 according to local time.
Date.getDaymyDate.getDay()Returns the day of the week from 0 (Sunday) to 6 (Saturday) according to local time.
Date.getFullYearmyDate.getFullYear()Returns the four-digit year according to local time.
Date.getHoursmyDate.getHours()Returns the hour from 0 (midnight) to 23 (11 p.m.) according to local time.
Date.getMillisecondsmyDate.getMilliseconds()Returns the milliseconds from 0 to 999 according to local time.
Date.getMinutesmyDate.getMinutes()Returns the minutes from 0 to 59 according to local time.
Date.getMonthmyDate.getMonth()Returns the month from 0 (January) to 11 (December) according to local time.
Date.getSecondsmyDate.getSeconds()Returns the seconds from 0 to 59 according to local time.
Date.getTimemyDate.getTime()Returns the number of milliseconds since midnight January 1, 1970, universal time.
Date.getTimezoneOffsetmydate.getTimezoneOffset()Returns the difference, in minutes, between the computer's local time and the universal time.
Date.getUTCDatemyDate.getUTCDate()Returns the day (date) of the month from 1 to 31 according to universal time.
Date.getUTCDaymyDate.getUTCDay()Returns the day of the week from 0 (Sunday) to 6 (Saturday) according to universal time.
Date.getUTCFullYearmyDate.getUTCFullYear()Returns the four-digit year according to universal time.
Date.getUTCHoursmyDate.getUTCHours()Returns the hour from 0 (midnight) to 23 (11 p.m.) according to universal time.
Date.getUTCMillisecondsmyDate.getUTCMilliseconds()Returns the milliseconds from 0 to 999 according to universal time.
Date.getUTCMinutesmyDate.getUTCMinutes()Returns the minutes from 0 to 59 according to universal time.
Date.getUTCMonthmyDate.getUTCMonth()Returns the month from 0 (January) to 11 (December) according to universal time.
Date.getUTCSecondsmyDate.getSeconds()Returns the seconds from 0 to 59 according to universal time.
Date.getYearmyDate.getYear()Returns an integer which, when added to 1900, gives the year according to local time. For instance, a return value of 0 means 1900.
Date.setDatemyDate.setDate(date)Sets the day of the month to date, an integer from 1 to 31, according to local time. Returns the new time in milliseconds.
Date.setFullYearmyDate.setFullYear (year [, month [, date]] )Sets a four-digit year, and optionally also the month from 0 (January) to 11 (December), and the date from 1 to 31, all according to local time. Returns the new time in milliseconds.
Date.setHoursmyDate.setHours(hour [, minute [, second [, millisecond]]])Sets the hour, from 0 (midnight) to 23 (11 p.m.); and optionally minute from 0 to 59; second from 0 to 59; and millisecond from 0 to 999, all according to local time. Returns the new time in milliseconds.
Date.setMillisecondsmyDate.setMilliseconds (millisecond)Sets the milliseconds according to local time from 0 to 999. Returns the new time in milliseconds.
Date.setMinutesmyDate.setMinutes (minute [, second [, millisecond]])Sets minute from 0 to 59; and optionally second from 0 to 59; and millisecond from 0 to 999, all according to local time. Returns the new time in milliseconds.
Date.setMonthmyDate.setMonth (month [, date ])Sets the month from 0 (January) to 11 (December) and optionally the date from 1 to 31, both according to local time. Returns the new time in milliseconds.
Date.setSecondsmyDate.setSeconds (second [, millisecond]))Sets the second from 0 to 59, and optionally the millisecond from 0 to 999, both according to local time. Returns the new time in milliseconds.
Date.setTimemyDate.setTime (millisecond)Sets the date, expressed in milliseconds since midnight on January 1, 1970. Returns the same number you give it.
Date.setUTCDatemyDate.setUTCDate (date)Sets the date according to universal time, from 1 to 31. Returns the new time in milliseconds.
Date.setUTCFullYearmyDate.setUTCFullYear (year [, month [, date]])Sets a four-digit year, and optionally also the month from 0 (January) to 11 (December), and the date from 1 to 31, all according to universal time.
Date.setUTCHoursmyDate.setUTCHours (hour [, minute [, second [, millisecond]]])Sets the hour, from 0 (midnight) to 23 (11 p.m.); and optionally minute from 0 to 59; second from 0 to 59; and millisecond from 0 to 999, all according to universal time. Returns the new time in milliseconds.
Date.setUTCMillisecondsmyDate.setUTCMilliseconds (millisecond)Sets millisecond from 0 to 999 according to universal time. Returns the new time in milliseconds.
Date.setUTCMinutesmyDate.setUTCMinutes (minute [, second [, millisecond]])Sets minute from 0 to 59; and optionally second from 0 to 59; and millisecond from 0 to 999, all according to universal time. Returns the new time in milliseconds.
Date.setUTCMonthmyDate.setUTCMonth (month [, date])Sets the month from 0 (January) to 11 (December) and optionally the date from 1 to 31, both according to universal time. Returns the new time in milliseconds.
Date.setUTCSecondsmyDate.setUTCSeconds (second [, millisecond]))Sets the second from 0 to 59, and optionally the millisecond from 0 to 999, both according to universal time. Returns the new time in milliseconds.
Date.setYearmyDate.setYear(year)Determines the value that will be retrieved by Date.getYear(). The year argument is an integer. If year is a one- or two-digit number, Date.getYear() retrieves that number. If year is three or more digits, Date.getYear() retrieves that number minus 1900.
Date.toStringmyDate.toString()Returns a string representing the date and time in this format: Sat May 4 12:42:19 GMT-0700 2002.
Date.UTCDate.UTC(year, month [, date [, hour [, minute [, second [, millisecond ]]]]])Returns the number of milliseconds between midnight on January 1, 1970, universal time, and the date/time specified in the arguments year, month, date, hour, minute, second, and millisecond.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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