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