clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

How To Calculate Number Of Days Between Two Dates Using jQuery

writter  Sumit Dey Sarkar
Date  23 Aug 2022
Language  JQuery
How To Calculate Number Of Days Between Two Dates Using jQuery

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