-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (25 loc) · 918 Bytes
/
script.js
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
const day = document.getElementById('day')
const hour = document.getElementById('hour')
const minute = document.getElementById('minute')
const second = document.getElementById('second')
const Ramadan = '1 mar 2025'
const countDown = ()=>{
const RamadanDate = new Date(Ramadan)
const currentDate = new Date();
const totalSeconds = (RamadanDate - currentDate) / 1000;
const days = Math.floor(totalSeconds / 3600 / 24)
const hours = Math.floor(totalSeconds / 3600) % 24
const minutes = Math.floor(totalSeconds / 60) % 60
const seconds = Math.floor(totalSeconds) % 60;
day.innerHTML = days;
hour.innerHTML = formatTime(hours);
minute.innerHTML = formatTime( minutes);
second.innerHTML = formatTime(seconds);
// console.log(days, hours, minutes, seconds)
}
const formatTime = (time)=>{
return time < 10 ? `0${time}` : time;
}
// initia;
countDown()
setInterval(countDown, 1000)