Create a Date object:
var now = new Date ();
var now= new Date ();d ocument.write (now); Tue APR 11:43:53 gmt+0800 (China Standard Time)
When you call the date constructor without passing parameters, the newly created object automatically obtains the current date and time. If you want to create an object based on a specific date and time, you must pass in the number of milliseconds that represent that date (that is, the number of milliseconds from midnight UTC January 1, 1970 to that date).
The Date.parse () method receives a string parameter that represents a date, and then returns the number of milliseconds for the corresponding date. Example: Create a Date object for April 19, 2016
var today = new Date (Date.parse ("April 19,2016"));
If the string passed into the Date.parse () method cannot represent a date, it returns Nan, and if the character that represents the date is passed to the date constructor, the Date.parse () is called in the background.
The DATE.UTC () method also returns the number of milliseconds that represents a date , but it uses different information with date.parse () when it is built. The arguments for DATE.UTC () are the year, based on the month of 0 (0-11), the Day of the month (1-31), the number of hours (0-23), minutes, seconds, and milliseconds. The first two parameters (year and month) are required.
Cases:
GMT April 19, 2016 PM 10:28:55var date= new Date (DATE.UTC (2016,3,19,10,28,55));
The Date.now () method, which returns the number of milliseconds that represents the date and time when this method was called. This approach simplifies the work of parsing code using date objects.
var start=date.now (); var start = +new Date (); alert (start); 1461037311016 (milliseconds)
Using the + operator to convert a Date object to a string can also achieve the above purpose.
The toLocaleString () method of the date type returns the date and time in a format that is appropriate for the locale that is set by the browser.
The ToString () method of the date type typically returns the date and time with the time zone information.
The valueof () method of the date type, which returns the millisecond representation of the day.
......
5.3 Date Type