views:

912

answers:

1

Hy!

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

How can I calculate the number of days between Date1 and Date2 ?

tks guys!

+1  A: 

Something like this:

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);
}
Charles
return Math.round(diff / days);
Chris