Date objects are used to handle dates and times.
Syntax for creating Date objects:
var myDate=new Date()
Date objects will automatically save the current date and time as their initial values.
There are the following 5 parameter forms:
new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);
Note that the last form, the parameter represents the time to be created and the GMT time of 1970 The number of milliseconds between January 1st. The meanings of various functions are as follows:
month: Use English to represent the month name, from January to December
mth: Use integers to represent the month, from (January) to 11 (December)
dd: indicates the day of the month, from 1 to 31
yyyy: the four-digit year
hh: hour, from 0 (midnight) to 23 (11 p.m.)
mm: minutes, an integer from 0 to 59
ss: seconds, an integer from 0 to 59
ms: milliseconds Number is an integer greater than or equal to 0
such as:
new Date("January 12,2006 22:19:35");
new Date("January 12,2006");
new Date(2006,0,12,22,19, 35);
new Date(2006,0,12);
new Date(1137075575000);
Date() returns the date and time of the current day.
getDate() returns the day of the month (1 ~ 31) from the Date object.
getDay() returns the day of the week (0 ~ 6) from the Date object.
getMonth() returns the month (0 ~ 11) from the Date object.
getFullYear() Returns the year as a four-digit number from a Date object.
getYear() Please use getFullYear() method instead.
getHours() returns the hours (0 ~ 23) of the Date object.
getMinutes() returns the minutes (0 ~ 59) of the Date object.
getSeconds() returns the seconds (0 ~ 59) of the Date object.
getMilliseconds() returns the milliseconds (0 ~ 999) of the Date object.
getTime() returns the number of milliseconds since January 1, 1970.
getTimezoneOffset() returns the difference in minutes between local time and Greenwich Mean Time (GMT).
getUTCDate() Returns the day of the month (1 ~ 31) from a Date object based on universal time.
getUTCDay() Returns the day of the week (0 ~ 6) from a Date object based on universal time.
getUTCMonth() returns the month (0 ~ 11) from a Date object based on universal time.
getUTCFulYear() Returns the four-digit year from a Date object based on universal time.
getUTCHours() returns the hour (0 ~ 23) of the Date object according to universal time.
getUTCMinutes() returns the minutes (0 ~ 59) of a Date object according to universal time.
getUTCSeconds() returns the seconds (0 ~ 59) of a Date object according to universal time.
getUTCMilliseconds() returns the milliseconds (0 ~ 999) of the Date object according to universal time.
parse() returns the number of milliseconds from midnight on January 1, 1970 to the specified date (string).
setDate() sets the day of the month (1 ~ 31) in the Date object.
setMonth() sets the month (0 ~ 11) in the Date object.
setFullYear() sets the year (four digits) in the Date object.
setYear() Please use setFullYear() method instead.
setHours() sets the hours (0 ~ 23) in the Date object.
setMinutes() sets the minutes (0 ~ 59) in the Date object.
setSeconds() sets the seconds (0 ~ 59) in the Date object.
setMilliseconds() sets the milliseconds (0 ~ 999) in the Date object.
setTime() sets a Date object in milliseconds.
setUTCDate() Sets the day of the month (1 ~ 31) in the Date object according to universal time.
setUTCMonth() Sets the month (0 ~ 11) in the Date object according to universal time.
setUTCFulYear() Sets the year (four digits) in the Date object according to universal time.
setUTCHours() Sets the hour (0 ~ 23) in the Date object according to universal time.
setUTCMinutes() Sets the minutes (0 ~ 59) in the Date object according to universal time.
setUTCSeconds() Sets the seconds (0 ~ 59) in the Date object according to universal time.
setUTCMilliseconds() Sets the milliseconds (0 ~ 999) in the Date object according to universal time.
toSource() returns the source code of the object.
toString() Converts Date object to string.
toTimeString() Converts the time part of the Date object to a string.
toDateString() Converts the date part of the Date object to a string.
toGMTString() Please use toUTCString() method instead. 1 3
toUTCString() Converts a Date object to a string according to universal time.
toLocaleString() Converts Date object to string according to local time format.
toLocaleTimeString() Converts the time part of the Date object into a string according to the local time format.
toLocaleDateString() Converts the date part of the Date object to a string according to the local time format.
UTC() Returns the number of milliseconds from January 1, 1997 to the specified date according to universal time.
valueOf() returns the original value of the Date object.
var objDate=new Date([arguments list]);