JSFiddle - React, Tailwind, and code Playground

HTML

<input type='text' id="lastAssimilationDate"/>
<input type='text' id="lastAssimilationDateOver"/>
<button>press</button>

JavaScript

$( "#lastAssimilationDate" ).datepicker({
                            yearRange: "-20:+100",
                            changeMonth: true,
                            changeYear: true,
                            dateFormat: "d-M-y"
                        });
                


                        $( "#lastAssimilationDateOver" ).datepicker({
                            yearRange: "-20:+100",
                            changeMonth: true,
                            changeYear: true,
                            dateFormat: "d-M-y"
                        });


function monthDiff(d1, d2) {
    var months;
    months = (d2.getFullYear() - d1.getFullYear()) * 12;
    months -= d1.getMonth() + 1;
    months += d2.getMonth();
    return months <= 0 ? 0 : months;
}

$('button').click(function(){
    d1 = new Date($( "#lastAssimilationDate" ).val());
    d2 = new Date($( "#lastAssimilationDateOver").val());
    alert(monthDiff(d1, d2));
});