JQuery.datePicker - calculate days

Hy!

I am using the jquery.datePicker example from Kelvin Luck. ( http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerClickInput.html )

How to calculate the number of days between Date1 and Date2?

tks guys!

+1


a source to share


2 answers


Something like that:



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

      

+2


a source


Don't forget the function name Math .:



return Math.round(diff / days);

      

+1


a source







All Articles