计算两天之间的天数差

       var today = new Date();
            var time = '2016-10-05';
            time = new Date(time);
            var g = getDays(today,time);
            console.log(g);
            
            function getDays(date1, date2) {
                var getd = (date1.getTime() - date2.getTime()) / (3600 * 24 * 1000);
                getd = parseInt(getd);
          return getd;
 }

 

posted @ 2017-08-22 17:48  小盆友灬  阅读(385)  评论(0编辑  收藏  举报