Data type
The data type saves the date using the number of milliseconds since UTC (International coordination Time) January 1, 1970 midnight.
Create a Date object:
var New Date (); Console.log (now); // Sun June 17:43:32 gmt+0800 (China Standard Time)
Methods for creating Date objects
date.parse (): accepts a string argument that represents a date, EC5 does not define the date appropriate for the support, and the behavior is realistic.
Browser Settings for United States:
"Month/day/year" 6/13/2016
"English month name Day, year" January 13,2016
English day of the week English month name: minutes: Seconds time zone Tue 2004 00:00:00 GTM-0700
var New Date (Date.parse ("May, 2004")); Console.log (somedate); // Tue 2004 00:00:00 gmt+0800 (China Standard Time)
Returns Nan if the passed-in string cannot represent a date;
DATE.UTC ():
var New Date (DATE.UTC (2005, 4, 5, +,)); Console.log (time); // Fri 2005 01:55:55 gmt+0800 (China Standard Time)
Month based on 0 start
Date constructor:
The date and time are created based on the local time zone.
var New Date (0, 0); Console.log (sometime); // Fri Dec 1999 00:00:00 gmt+0800 (China Standard Time)
var New Date (2005, 4, 5, N, +); Console.log (sometime); // Thu 2005 17:55:55 gmt+0800 (China Standard Time)
Methods of Inheritance
toLocaleString () and ToString ():
Different browsers behave differently. useful when debugging code;
ValueOf (): Returns the millisecond representation of the date. Can be used to compare date values.
var New Date (0, 1); var New Date (1, 1>< date2); // false // true
Fifth reference type > Data type