Call the function passing 2 dates and it returns the difference in days

// 
function diffdate(d1,d2){
var WNbJours = d2.getTime() - d1.getTime(); return Math.ceil(WNbJours/(1000*60*60*24));
}