I want to have the difference of months between two dates. But I'm missing something. I want to type the dates in the inputs and the result appears in another input.
var DateDiff = {
inMonths: function(d1, d2) {
var d1Y = d1.getFullYear();
var d2Y = d2.getFullYear();
var d1M = d1.getMonth();
var d2M = d2.getMonth();
return (d2M+12*d2Y)-(d1M+12*d1Y);
}}
var dataInicio= document.getElementById("dataInicio");
var dataFinal = document.getElementById("dataFinal");
document.write("<br />Numero de <b>months</b> since "+dataInicio+": "+DateDiff.inMonths(dataInicio, dataFinal));