-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (22 loc) · 853 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (22 loc) · 853 Bytes
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
setInterval(() => {
const now = new Date()
const currentYear = now.getFullYear()
const goal = new Date(currentYear, 11, 25)
const totalSeconds = goal - now
function prettier(id) {
if (id.textContent.length == 1) {
const array = Array.from(id.textContent)
array.unshift('0')
id.textContent = array.join('')
}
}
days.children[0].textContent = Math.floor((totalSeconds / 1000 / 60 / 60 / 24))
hours.children[0].textContent = Math.floor(((totalSeconds / 1000 / 60 / 60) % 24))
minutes.children[0].textContent = Math.floor(((totalSeconds / 1000 / 60) % 60))
seconds.children[0].textContent = Math.floor(((totalSeconds / 1000) % 60))
prettier(days.children[0])
prettier(hours.children[0])
prettier(minutes.children[0])
prettier(seconds.children[0])
console.log((totalSeconds / 1000) % 60)
}, 1000)