<SCRIPT LANGUAGE="JavaScript">
<!--
var strDate1 = "2004-09-17 03:03:00.0";
var strDate2 = "2004-09-17 04:05:00.0";
strDate1=strDate1.substring(0,strDate1.lastIndexOf(".")).replace(/-/g,"/");
strDate2=strDate2.substring(0,strDate2.lastIndexOf(".")).replace(/-/g,"/");
var date1 = Date.parse(strDate1);
var date2 = Date.parse(strDate2);
alert("strDate2与strDate1相差"+(date2-date1)/(60*60*1000)+"小时")
alert("strDate2与strDate1相差"+(date2-date1)/(60*60*1000*24)+"天")
//-->
</SCRIPT>
javascript日期相减
最新推荐文章于 2024-08-27 15:36:53 发布