1. 程式人生 > >計算兩天之間的天數差

計算兩天之間的天數差

logs () turn bsp .get urn ret int code

       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;
 }

計算兩天之間的天數差