Примерно так:
function returnNumberOfDaysBetweenTwoDates(input1, input2) {
var date1 = new Date(input1.value);
var date2 = new Date(input2.value);
var minutes = 1000*60;
var hours = minutes*60;
var days = hours*24;
var diff = Math.abs(date1.getTime() - date2.getTime());
return round(diff / days);
}