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