Calculate in time format

0

I need help to create a time calculation. I have a field:

Hora inicial <input id="inicial")>
Hora final <input id="final">
Total de horas <input id="resultado">

I can add integer value (00), but as it is in the format of hours (00:00) it gives the calculation error.

I know very little of JavaScript, can anyone force it?

I tried this:

<script type="text/javascript"> function calcular(){
   var n1 = parseInt(document.getElementById('n1').value, 10);
   var n2 = parseInt(document.getElementById('n2').value, 10);
   document.getElementById('resultado').innerHTML = n1 - n2;   
} 
</script>

If I pass a value as follows: 2:00 p.m. for n1 16:00 for n2

It does not display the 2 that is the result.

I want to know how much time is between 14:00 and 16:00.

I just need to know the difference on the same day, it will not be more than 24h so I can not change my date and return time. as suggested.

    
asked by anonymous 18.08.2016 / 05:47

0 answers