JavaScript两个日期相减

<script>
var sDate="2007-06-06";
var eDate="2007-07-07";
var sArr = sDate.split("-");
var eArr = eDate.split("-");
var sRDate = new Date(sArr[0], sArr[1], sArr[2]);
var eRDate = new Date(eArr[0], eArr[1], eArr[2]);
var result = (eRDate-sRDate)/(24*60*60*1000);
alert(result);
</script>

你可能感兴趣的:(JavaScript,Date)