Create a date object:
Copy codeThe Code is as follows:
Var objDate = new Date ([arguments list]);
The following five parameters are supported:
1) new Date ("month dd, yyyy hh: mm: ss ");
2) new Date ("month dd, yyyy ");
3) new Date (yyyy, mth, dd, hh, mm, ss );
The third initialization method I used in the program always shows that the formatting parameters are incorrect. After carefully reading the information, it must be an integer. What I pass is a string.
4) new Date (yyyy, mth, dd );
5) new Date (MS );
Note the last form. The parameter represents the number of milliseconds between the creation time and the GMT time of January 1, January 1, 1970. The meanings of various functions are as follows:
Month: represents the name of a month in English, from January to December.
Mth: an integer representing the month, from (January 1, January) to 11 (January 1, December)
Dd: the day of a month, from 1 to 31.
Yyyy: The Year in four-digit format.
Hh: hours, from 0 (midnight) to 23)
Mm: The number of minutes, an integer from 0 to 59.
Ss: number of seconds, an integer from 0 to 59
Ms: Number of milliseconds, an integer greater than or equal to 0
For example:
Copy codeThe Code is as follows:
New Date ("January 12,2006 22:19:35 ");
New Date ("January 12,2006 ");
New Date );
New Date (2007,0, 12 );
New Date (1137075575000 );
All the above creation forms indicate the day of June 1, January 12, 2006.