Функция

var differenceTwoDates = function(date1, date2) {
    var oneDay = 864E5;
    var diff = Math.abs(date1.getTime() - date2.getTime());
    return Math.round(diff / oneDay);
};

Применение

var oneDate = new Date("12/12/2014");
var secondDate = new Date("12/10/2014");    
var difference = differenceTwoDates(oneDate, secondDate);

Демо

Теги: javascript

Редактировать