First get Days from Your Dates and then take difference of that.
var SecondDate = new Date(31-Aug-2014);
var FirstDate = new Date(28-Aug-2014);
var SecondDateDay = SecondDate.getDay();
var FirstDateDay = FirstDate.getDay();
var DayDif = SecondDateDay - FirstDateDay
alert(DayDif);