-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudi_kasus.js
More file actions
22 lines (16 loc) · 778 Bytes
/
studi_kasus.js
File metadata and controls
22 lines (16 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// program hitung mundur
const tanggalTujuan = new Date("Jun 2, 2024 14:41:00").getTime();
const hitungMundur = setInterval(() => {
const sekarang = new Date().getTime();
const selisih = tanggalTujuan - sekarang;
const hari = Math.floor(selisih / (1000 * 60 * 60 * 24));
const jam = Math.floor(selisih % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
const menit = Math.floor(selisih % (1000 * 60 * 60) / (1000 * 60));
const detik = Math.floor(selisih % (1000 * 60) / 1000);
const teks = document.getElementById("teks");
teks.innerHTML = `Waktu anda tinggal: ${hari} hari, ${jam} jam, ${menit} menit, ${detik} detik lagi`;
if (selisih <= 0) {
clearInterval(hitungMundur);
teks.innerHTML = "Waktu anda HABIS!"
}
}, 1000);