1, Date.now ()
Date.now () is in ECMAScript 5
//prior to, use +new Date ()
//Get current time
var now = (typeof Date.now = = "Funct Ion "? Date.now (): +new Date ());
Alert ("Right now:" + now);
2, Date.parse () method
var now = new Date ();
alert (now);
var somedate = new Date (Date.parse ("May)");
The parse () method resolves a date-time string and returns the number of milliseconds from the 1970/1/1 midnight distance from that date time.
alert (somedate);
3, Date UTC () and toutcstring () methods
The UTC () method returns the number of milliseconds from January 1, 1970 to a specified date based on the universal.
//DATE.UTC (YEAR,MONTH,DAY,HOURS,MINUTES,SECONDS,MS)/
* is
required. Represents a four-digit number for the year.
month required. An integer representing the month, between 0 ~ 11. Day
required. An integer representing the date, between 1 ~ 31.
hours optional. An integer that represents the hour, between 0 ~ 23.
minutes optional. An integer that represents the minute, between 0 ~ 59.
seconds optional. An integer representing the second, between 0 ~ 59.
Ms Optional. An integer representing milliseconds, between 0 ~ 999.
DATE.UTC () is a static method because it needs to be invoked by using the constructor date (), rather than by a Date object.
the parameters of the DATE.UTC () method specify the date and time, which are in UTC time and in GMT time zone. The specified UTC time is converted to milliseconds, so that
the constructor Date () and Method Date.settime () can be used. The
*
///toutcstring () method converts a Date object to a string based on Universal Time (UTC) and returns the result.
//january 1 at midnight
var y2k = new Date (DATE.UTC (0));
Alert (y2k.toutcstring ());
May 5, 5:55:55 PM GMT
var allfives = new Date (DATE.UTC (4, 5, MB,));
Alert (allfives.toutcstring ());
The above is today's JavaScript learning Summary, and will continue to update every day, I hope you continue to pay attention.