jda_m06/uf01/examen_jan_maroto/exercici_03.html
2022-02-16 16:13:08 +01:00

42 lines
1.1 KiB
HTML
Executable file

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Problema tercer conmpte enrrere</title>
</head>
<body>
<p id="ex03"></p>
<p id="ex03-2"></p>
<button onclick="startTimer()">Inicia rellotge</button>
<button onclick="stopTimer()">Atura rellotge</button>
<script>
function stopTimer() {
clearInterval(timer);
}
function printTimer() {
let newDate = new Date();
let nowDate = Date.parse(newDate);
let laterDate = newDate.setHours(23, 59, 59);
let timeRemaining = laterDate-nowDate;
//Mha faltat temps per a formatigar els milisegons de la variable anterior
let outputTime = ""
document.getElementById("ex03").innerHTML = timeRemaining ;
}
function startTimer() {
timer = setInterval(printTimer, 5000);
}
let timer = setInterval(printTimer, 5000);
</script>
</body>
</html>