This fails in IE 11 but works fine in Chrome. //where startDate is "10/17/2016"
var testDate1 = new Date(startDate);
This gives an invalid date in IE with the debugger, but works fine in Chrome.
According to MSDN, this should work https://msdn.microsoft.com/en-us/library/ff743760(v=vs.94).aspx
Another example, just playing with the date format
Am I missing something?
答案 0 :(得分:0)
For certain result you may split datestring and use new Date function as below. On Date constructor Months are array 0 to 11. So we have to use -1. If your datestring is not a valid date then below function returns null.
function MakeDate(DString) /*10/17/2016*/
{ DString=DString.split('/');
return new Date(DString[2], parseInt(DString[0])-1, DString[1]);
}