js 求两个日期之间相差天数

//求两个日期之间的相差天数
        function daysBetween(DateOne, DateTwo) {
            var OneMonth = DateOne.substring(5, DateOne.lastIndexOf(‘/‘));
            var OneDay = DateOne.substring(DateOne.length, DateOne.lastIndexOf(‘/‘) + 1);
            var OneYear = DateOne.substring(0, DateOne.indexOf(‘/‘));

            var TwoMonth = DateTwo.substring(5, DateTwo.lastIndexOf(‘/‘));
            var TwoDay = DateTwo.substring(DateTwo.length, DateTwo.lastIndexOf(‘/‘) + 1);
            var TwoYear = DateTwo.substring(0, DateTwo.indexOf(‘/‘));

            var cha = ((Date.parse(OneMonth + ‘/‘ + OneDay + ‘/‘ + OneYear) - Date.parse(TwoMonth + ‘/‘ + TwoDay + ‘/‘ + TwoYear)) / 86400000);
            return cha; //.abs(cha);求绝对值
        }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。