Create a date object:
Copy the code code as follows:
var objDate=new Date([arguments list]);
There are five types of parameter forms:
1) new Date("month dd,yyyy hh:mm:ss");
2) new Date("month dd,yyyy");
3) new Date(yyyy,mth,dd,hh,mm,ss);
In the third initialization method I used in the program, it always showed that the formatted parameters were incorrect. After careful inspection, they must be integers. What I passed was a string.
4) new Date(yyyy,mth,dd);
5) new Date(ms);
It should be noted that in the last form, the parameter represents the number of milliseconds difference between the time to be created and January 1, 1970 GMT time. The meanings of various functions are as follows:
month: Indicates the name of the month in English, from January to December
mth: Use an integer to represent the month, from (January) to 11 (December)
dd: indicates the day of the month, from 1 to 31
yyyy: four-digit year
hh: hour, from 0 (midnight) to 23 (11 p.m.)
mm: Minutes, an integer from 0 to 59
ss: seconds, an integer from 0 to 59
ms: milliseconds, an integer greater than or equal to 0
like:
Copy the code code as follows:
new Date("January 12,2006 22:19:35");
new Date("January 12,2006");
new Date(2006,0,12,22,19,35);
new Date(2006,0,12);
new Date(1137075575000);
The various creation forms above all represent the day January 12, 2006.