title: Calculate hours between two datetime-local inputs
body: <p>I'm trying to get the difference in hours between two datetime-local inputs (start and end date). I'm trying to do it with momentjs library without success. I know that the problem is in the format of the datetime-local inputs, but, there's any way to format it to allow Momentjs to get it and compare? Or should I try with a different library/input? </p>
  
  <pre><code>&lt;input type="datetime-local" name="input-time" id="start-time"&gt;
  &lt;input id="end-time" type="datetime-local" onchange="myFunction()"&gt;
  &lt;input type="text" id="total-hours" placeholder="Total Hours"&gt;              
  
  function myFunction() {
    var initialTime=document.getElementById("start-time");
    var initialTimeFormat=moment(initialTime);
    var endTime=document.getElementById("end-time");
    var endTimeFormat=moment(endTime);
    var totalHours=endTimeFormat.diff(initialTimeFormat,"hours");
    $("#total-hours").text(totalHours); 
    }
  </code></pre>