This article introduces how to solve js new date () function not supported in IE browser. For more information, see.
Solution 1
| The Code is as follows: |
Copy code |
|
Function NewDate (str ){
If (str = null)
Return false;
Str = str. split ('-');
Var date = new Date ();
Date. setUTCFullYear (str [0], str [1]-1, str [2]);
Date. setUTCHours (0, 0, 0, 0 );
Return date;
} |
Solution 2
| The Code is as follows: |
Copy code |
Function getDays (strDateStart, strDateEnd ){
Var strSeparator = "-"; // Date Separator
Var oDate1;
Var oDate2;
Var iDays;
ODate1 = strDateStart. split (strSeparator );
ODate2 = strDateEnd. split (strSeparator );
Var strDateS = new Date (oDate1 [0], oDate1 [1]-1, oDate1 [2]);
Var strDateE = new Date (oDate2 [0], oDate2 [1]-1, oDate2 [2]);
IDays = parseInt (Math. abs (strDateS-strDateE)/1000/60/60/24) // converts the number of milliseconds to the number of days
Return iDays;
} |