The date type stores dates using the number of milliseconds that have elapsed since midnight UTC January 1, 1970.
Create Date Object
var New Date (); // Get Current date
Date.parse () accepts a string parameter that represents a date, returning the corresponding number of milliseconds. This date format usually varies by region. In fact, the date string is passed directly to the dates constructor, and the background is called date.parse (), so the following two are equivalent
var New Date (Date.parse ("May, 2004")); var New Date ("May 25, 2004");
The DATE.UTC () parameters are the year, the month (0-11), the Day (1-31), The Hour (0-23), the minute, the second, and the number of milliseconds. Omitted parameters are automatically populated with 0 (days of 1) and the same UTC parameter can be passed directly to the date constructor
// May 5, 2005 PM 5:55:55 var New Date (DATE.UTC ("2005, 4, 5, N, N,")); var New Date ("2005, 4, 5, 17, 55, 55");
Date.now () returns the number of milliseconds in the current moment
Methods of InheritanceThe date tolocalestring () returns the day and time (will contain AM or PM) but does not contain the time zone information ToString () returns the date time with the time zone information Chrome Firefox date.valeuof () will return a millisecond representation of the date, So the date size can be compared
method of formattingThe last two results vary by browser, but toUTCString () is recommended.
Date/Time component methodGet or set a specific value directly
Get/settime () get/set (UTC) Fullyear () get/set (UTC) Month () get/set (UTC) Date ()get (UTC) Day () Get/set (UTC) Hours () get/set (UTC) Minutes () get/set (UTC) Seconds () get/set (UTC) Milliseconds () getTimezoneOffset Returns the number of minutes between local and UTC time
Javascript Date Type