To create a one -date object, you can use the following methods:
Copy code code as follows:
var now = new date ()
Of course, no parameters are passed in the function, indicating that this object has automatically obtained the current time.
If you want to create an object of a custom time, the parameter is transferred to the date (). And this parameter must be milliseconds (UTC time January 1, 1970 from midnight to the milliseconds from the custom time).
We can use date.parse () and date.utc () to obtain the milliseconds of the custom time.
Date.parse () receives a string parameter that indicates the date, such as "May 25,2013", "6/13/2013" and other formats. The specific format that supports is different from the region.
The parameters received in date.utc () are the year, the number of months from 0 (0-11), the first days (1-31) in the middle of the month, the hour tree (0-23), the minute, the minute, second , Milliseconds, the number of years and the month is required, and other parameters are default to 0.
If we want to define a date object on December 12, 2013, we can use date.parse ():
var mydate = new date (date.parse ("12/12/2013"),
If so:
Var mydate = new date ("" 12/12/2013 "), when constructing Date, the date.parse () will automatically call the date string to milliseconds.
You can also use date.utc ():
var mydate = new date (date.utc (2013,11,12) // Note that the monthly bidding starts from 0, and the daily subsidy starts from 1
If so:
Var mydate = new date (2013,11,12), similar to the constructor of PARSE above, when the constructed date object, the date.utc () will be automatically called. If the first parameter is the value, take it as the year, and the year, and the year, and the year, and the year, and the year, and the year, and the year, and the year, and the year, and the year, and the year, and it is the year, and it is the year, and it will be the year, and it will be regarded as the year. The second parameter is the month ... but it should be noted that the former Var Mydate = New Date (Date.utc (2013,11,12) gets GMT time, while the latter Var mydate = new date (2013 , 11,12) Get the local time based on the system.