I\'m writing an equipment rental application where clients are charged a fee for renting equipment based on the duration (in days) of the rental. So, basically, (daily fee *
use setHours() method, assuming number of days can never be zero :)
function dateDiff1(startDate, endDate) { endDate.setHours(0); startDate.setHours(0); //assuming days cannt be 0. var x = ((endDate.getTime() - startDate.getTime()) / 1000*60*60*24); if (x <1 && x>=0) { return 1; } return x; }