Get difference between 2 dates in JavaScript

 <script>

    function dateDiffInDays() {

        const date1 = new Date(document.getElementById("AgeFrom").value);

        const date2 = new Date(document.getElementById("AgeTo").value);

        const diffTime = Math.abs(date2 - date1);

        const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));

        alert(diffDays + " days");

    }

</script>