In this tutorial im going to learn how to get difference between two dates using jquery. Using below example i can calculate difference dates in days in jquery, we can get simply difference between two dates in jquery
Example :-
<!DOCTYPE html>
<html>
<head>
<title>get difference between two dates in days using jQuery</title>
</head>
<body>
<script type="text/javascript">
var days1 = daysdifference('10/11/2023', '10/25/2023');
console.log(days1);
function daysdifference(firstDate, secondDate){
var startDay = new Date(firstDate);
var endDay = new Date(secondDate);
var millisBetween = startDay.getTime() - endDay.getTime();
var days = millisBetween / (1000 * 3600 * 24);
return Math.round(Math.abs(days));
}
</script>
</body>
</html>
Output :-