閱讀962 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Date.parse Firefox返回Nan的解決辦法

不知何故,firefox對於類似“2010-12-20 15:55:00”這種時間的轉換格式不感冒,返回Nan,查了查資料,把“-”替換為“/”就可以了;

 

<mce:script type="text/javascript"><!-- var inputDate="2010-12-20 15:55:00"; inputDate=inputDate.replace("-", "/").replace("-", "/"); var nowDate=new Date(); //alert(Date.parse(inputDate)) //alert(Date.parse(nowDate)) if(Date.parse(inputDate)<Date.parse(nowDate)) { alert("對不起,輸入時間不能晚於當前時間!"); } // --></mce:script>  

最後更新:2017-04-02 06:51:33

  上一篇:go Jquery實現頁麵定時跳轉
  下一篇:go 程序員VS.藝術家