The JavaScript date function consists of the following 20 functions:
(1) getDate function: Returns the day portion of the date with a value of 1~31. Cases:
function Datedemo () {var d, s = "Today ' s date is:"; D = new Date (); s + = (D.getmonth () + 1) + "/"; s + = D.getdate () + "/"; s + = D.getyear (); return (s); }
(2) GetDay function: Returns the day of the week with a value of 0~6, where 0 represents Sunday, 1 represents Monday, ..., and 6 means Saturday. Cases:
function Datedemo () {var d, day, x, s = ' Today is: '; var x = NewArray ("Sunday", "Monday", "Tuesday"); var x =x.concat ("Wednesday", "Thursday", "Friday"); var x =x.concat ("Saturday"); D = new Date (); Day = D.getday (); return (s + = X[day]); }
(3) getHours function: Returns the "hour" portion of the date, with a value of 0~23. Cases.
function Timedemo () {var d, s = "The currentlocal time is:"; var c = ":"; D = new Date (); s + = d.gethours () + C; s + = D.getminutes () + C; s + = D.getseconds () + C; s + = D.getmilliseconds (); return (s); }
(4) getminutes function: Returns the "minute" part of the date with a value of 0~59. See the example above.
(5) getMonth function: Returns the month portion of the date with a value of 0~11. 0 means January, 2 means March, ..., and 11 means December. See the previous example.
(6) getseconds function: Returns the "seconds" portion of the date, with a value of 0~59. See the previous example.
(7) getTime function: Returns the system time.
function Gettimetest () {var d, s, t; var Minmilli = 1000 * 60; var Hrmilli = Minmilli *60; var Dymilli = Hrmilli *24; D = new Date (); t = D.gettime (); s = "It ' s been" s + = Math.Round (T/dymilli) + "days since 1/1/70"; return (s); }
(8) gettimezoneoffset function: Returns the difference in this area (local time versus GMT Greenwich Mean Time) in minutes.
function Tzdemo () {var d, tz, s = "thecurrent local time is"; D = new Date (); TZ =d.gettimezoneoffset (); if (TZ < 0) S + = tz/60 + "hours before GMT"; else if (TZ = = 0) s + = "GMT"; else S + = tz/60 + "hours after GMT"; return (s); }
(9) getYear function: Returns the "year" part of the date. The return value is based on a 1900-year base, for example, 1999 is 99. There is an example above.
(10) Parse function: Returns the number of milliseconds (local time) that was counted from zero January 1, 1970.
function Gettimetest (testdate) {var d, s, t; var Minmilli = 1000 * 60; var Hrmilli = Minmilli *60; var Dymilli = Hrmilli *24; D = new Date (); t = Date.parse (testdate); s = "There is" s +=math.round (Math.Abs (T/dymilli)) + "Days" s + = "between" + TestDate + "and 1/1/70"; return (s); }
(11) setDate function: Sets the day of the date section with a value of 0~31.
(12) sethours function: Sets the "hour" portion of the date, and the value is 0~23.
(13) setminutes function: Sets the "minute" portion of the date, and the value is 0~59.
(14) setmonth function: Sets the month portion of the date, and the value is 0~11. 0 of them represent January, ..., 11 means December.
(15) setseconds Function: Sets the date's "Seconds" section with a value of 0~59.
(16) settime function: Set the time. The time value is the number of milliseconds since January 1, 1970 when the integer count is zero.
(17) setyear function: The "Year" section of the set date.
(18) togmtstring Function: Converts the date into a string that is GMT Greenwich Standard Time.
(19) setlocalestring Function: Converts the date into a string, for local time.
(20) UTC function: Returns the number of milliseconds from January 1, 1970 to the full count, measured in GMT Greenwich Mean time.
(21) toString Function: Converts a Date object to a string, using local time
(22) valueOf function: Returns the number of milliseconds from January 1, 1970 when the integer is counted.