jQuery

jQuery get Difference between two Dates in days

<script type="text/javascript">
    var days = daysdifference('03/05/2022', '03/05/2022');
    console.log(days);

    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>

Get The latest Coding solutions.

Subscribe to the Email Newsletter