Format and calculate days between two dates [duplicate]

In my Laravel blade I’ve 2 date fields with format d.m.Y
Trying to calculate the days between them and outputting the result in a 3rd field on the fly

Tried:

<script>
function diffIndays() {
   var startDate = Date.parse($('#start_date').val(); // value: 16.12.2022
   var endDate = Date.parse($('#end_date').val());    // value: 18.12.2022
   $('#days_count').val(endDate - startDate)
 }
   
 $("input").bind("keyup change", function () {
   diffIndays();
 });
</script>

But it produces invalid date when I console.log()

Also tried as mentioned in some answers

Get difference between 2 dates in JavaScript?

How to change Date format in JavaScript?

I got 2 problems in the above code as Javascript default date format MM/DD/YYYY is different than d.m.Y which requires conversion in my case and how do I calculate the days?
Your help is appreciated.