Get Date Difference in Days between Two Dates

  1. <script type="text/javascript">  
  2.     function daysBetween(startDate, endDate) {  
  3.         var millisecondsPerDay = 1000 * 60 * 60 * 24;  
  4.         var startDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());  
  5.         var endDateUTC = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());  
  6.   
  7.         return Math.floor((endDateUTC - startDateUTC) / millisecondsPerDay);  
  8.     }  
  9. </script>