I found a similar question here but this is not working for my case as my dates are in a specific format "yyyy-MM-dd" i.e. "2014-08-29" and "2014-08-31".
I tried below but not working as expected. "dtpEffectiveFrom" & "dtpEffectiveTo" both are HTML5 date field. For the above date range, output is showing NaN days instead of 3 days.
var effectiveFrom = $("#dtpEffectiveFrom").val();
var effectiveTo = $("#dtpEffectiveTo").val();
function daydiff(first, second) {
return (second - first) / (1000 * 60 * 60 * 24);
}
var msg = "Are you applying for a " + daydiff(effectiveFrom, effectiveTo) + " day(s) leave?";
alert(msg);