I'm doing something to calculate the sum of hours and minutes, and I see no solution.
I need to get a pasted time formatted so 09:00
, but with random time in a input
and clicking on submit change the html with the input time with addition of 70 minutes. I could not get past this part and I still have not tried to add the minutes.
Can anyone help me with this mission?
<html>
<head>
<title></title>
<span> hora inicio </span>
<script type="text/javascript">
function hora1(){
var horas = getElementById("hrs")
var hr1 = horas.split(":"); // a hora sera colada com ":" no input, entao preciso dar um split, separar minutos de hora e somar 70 minutos.
var hr2 = hr1[0]+":"+hr1[1]; // ainda preciso somar os minutos e mostrar na exibição final com os 70 minutos a mais dessa hora do input
m.innerHTML = hr2;
}
</script>
</head>
<body>
<div id="m">
09:50
</div>
<input type="text" id="hrs">
<button onclick="hora1()">TESTAR</button>
</body>
</html>
I got results but without the possibility of entering the time, which is not what I needed
<!-- EM JAVASCRIPT EM UM ARQUIVO PHP COM RESULTADO OK MAS RECEBENDO A HORA DO SISTEMA -->
<html>
<body>
<h2>Somar 70 minutos</h2>
<script type="text/javascript">
var mc = 1;
var mc5 = 20;
var d1 = new Date();
var d2 = new Date();
d1.setHours(+d2.getHours()+(mc) );
d1.setMinutes(new Date().getMinutes()+(mc5) );
document.write("#resultado: " + " " + d1.getHours()+":"+d1.getMinutes());
</script>
</body>
</div>
</html>