-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
49 lines (44 loc) · 1.39 KB
/
Copy pathindex.html
File metadata and controls
49 lines (44 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Controle de tempo</title>
</head>
<body>
<h2 id="relogio"></h2>
<script>
function atualizarRelogio(){
const agora = new Date();
const horas = agora.getHours().toString();
const minut = agora.getMinutes().toString();
const segun = agora.getSeconds().toString();
documen.getElementById("relogio").innerText = '$ {horas}:${minut}:${segun}';
}
setInterval(atualizarRelogio, 1000);
atualizarRelogio();
</script>
<hr>
<script>
let segundos = 0;
let intervalo;
function formatar(segundos){
const h = String(Math.floor(segundos/3600));
const m = String(Math.floor((segundos % 3600)/60));
const s = String(segundos % 60);
return '${h}:${m}:${s}';
}
function atualizarTimer(){
document.getElementById("timer").innerText = formatar(segundos);
}
function iniciar(){
if(!intervalo){
intervalo = setInterval(() => {
segundos++;
atualizarTimer();
}, 1000);
}
}
</script>
</body>
</html>