输入的生日日期大于当前时间时,提示错误信息
var arr = new Array(); arr = "04/08/2011".split("/"); dobJoin = arr[1] + "/" + arr[0] + "/" + arr[2]; alert(dobJoin); var dobValue = new Date(Date.parse(dobJoin)); var now = new Date(); //得到当前时间 alert(dobValue); alert(now); if(dobValue > now){ alert("Wrong time!"); }else{ alert("Right time"); }
//三种日期格式转换
<script language="JavaScript"> //alert("Date: "+Date.parse("2000-01-01")) // On IE and Mozilla: "Date: NaN" //alert("Date: "+Date.parse("01-01-2000")) // On IE: "Date: 946681200000" // On Mozilla: "Date: NaN" alert("Date: "+Date.parse("02/01/2000")) //日期格式mm/dd/yyyy alert("Date: "+Date.parse("2000/02/01")) //日期格式yyyy/mm/dd // On IE and Mozilla: "Date: 949334400000" alert("Date: "+Date.parse("01/02/2000")) //日期格式dd/mm/yyyy // On IE and Mozilla: "Date: 946742400000" </script>
JS中两个时间的比较
最新推荐文章于 2022-11-15 18:18:39 发布