计算两个日期间的天数

            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 Math.abs(cha);
            },

posted @ 2019-03-24 18:06  沧海一粟95  阅读(311)  评论(0编辑  收藏  举报