clock  Mon - Sun 8.00 AM - 8.00 PM
mail  edu@teknowize.com
fb
instagram
play store
pinterest

How To Calculate Number Of Days Between Two Dates Using jQuery

  Sumit Dey Sarkar
  23 Aug 2022
  JQuery
Imperial Advance Hero Image

How To Calculate Number Of Days Between Two Dates Using jQuery

In this tutorial we will learn how to calculate number of days between two dates using jQuery.

lets's see the example - 

How to calculate number of days between two dates using jQuery

<!DOCTYPE html>
<html>
<head>
    <title>How to calculate number of days between two dates using jQuery</title>
</head>
<body>
  
<script type="text/javascript">
   
var allDays = DatesForDifference('08/23/2022', '08/30/2022');
  
console.log(allDays);
  
function DatesForDifference(firstDate, secondDate){
    var startingDay = new Date(firstDate);
    var endingDay = new Date(secondDate);
   
    var millisBetween = startingDay.getTime() - endingDay.getTime();
    var allDays = millisBetween / (1000 * 3600 * 24);
   var totalDays= Math.round(Math.abs(allDays));
   alert('total days = ' + totalDays) ;
}
</script>
   
</body>
</html>

 

Output

jQuery