2
I’m doing something for hours and minutes sum calculation, and I see no solution.
I need to get a time stamp formatted like this 09:00
, but with random time on a input
and by clicking Submit change html with input time with 70 minutes added. I couldn’t get past that part and I haven’t even tried to add up the minutes.
Someone could help me on 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 typing 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>
What would be random horá ??
– GeekSilva
EXAMPLES: 07:53 or 20:35
– alex souza