IE FIREFOX日付表示でNaNが発生した問題について
JavaScript Date.parse
Date.parse Date , “ ,
1970 1 1 ”。 :
Date.parse(dateVal)
, , ,
, NaN, ,
, 。
, ,
parse “/” “-” , / / ,
“7/6/2008” “7-6-2008”, , “7-6-2008” ,
IE , FireFox , NaN。 ,
, “7/6 /2008” IE FF 。
Java
1. <html>
2. <head>
3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
4. <title>JavaScript Date.parse() </title>
5. </head>
6. <body>
7. <script type="text/javascript">
8. document.write(Date.parse(new Date()));
9. </script>
10.
11. </body>
12. </html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript Date.parse() </title>
</head>
<body>
<script type="text/javascript">
document.write(Date.parse(new Date()));
</script>
</body>
</html>
Which should be the correct date format for Date.parse ?
Let's go straight to the point:
Java
1. <script language="JavaScript">
2. alert("Date: "+Date.parse("2000-01-01"))
3. // On IE and Mozilla: "Date: NaN"
4.
5. alert("Date: "+Date.parse("01-01-2000"))
6. // On IE: "Date: 946681200000"
7. // On Mozilla: "Date: NaN"
8.
9. alert("Date: "+Date.parse("01/01/2000"))
10. alert("Date: "+Date.parse("2000/01/01"))
11. // On IE and Mozilla: "Date: 946681200000"
12. </script>
Date.parseDate(responseArray.salesdate .substring(0, 10),'Y-m-d')