js 计算日期天数

        function DateDiff() {
            var start = document.getElementById("TextBox1");
            var end = document.getElementById("TextBox2");
            var result = document.getElementById("TextBox3");

            var arrDate, objDate1, objDate2, intDays;
            arrDate = start.value.split("-");
            objDate1 = new Date(arrDate[1] + '-' + arrDate[2] + '-' + arrDate[0]);
            arrDate = end.value.split("-");
            objDate2 = new Date(arrDate[1] + '-' + arrDate[2] + '-' + arrDate[0]);
            intDays = parseInt(Math.abs(objDate1 - objDate2) / 1000 / 60 / 60 / 24);
            result.value = intDays;
        }

posted @ 2011-06-27 10:55  Devil_Nic  阅读(774)  评论(0编辑  收藏  举报