반응형
 datediff 구현

 

 


    function getDateDiff(date1,date2){
        var arrDate1 = date1.split("-");
        var getDate1 = new Date(parseInt(arrDate1[0]),parseInt(arrDate1[1])-1,parseInt(arrDate1[2]));
        var arrDate2 = date2.split("-");
        var getDate2 = new Date(parseInt(arrDate2[0]),parseInt(arrDate2[1])-1,parseInt(arrDate2[2]));

        var getDiffTime = getDate1.getTime() - getDate2.getTime();

        return Math.floor(getDiffTime / (1000 * 60 * 60 * 24));
    }

 

 

getDateDiff("2016-08-01","2016-07-21")

 

 

 

반응형

+ Recent posts