-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33f133b
commit c5d5e7f
Showing
1 changed file
with
46 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,55 @@ | ||
(function () { | ||
const second = 1000, | ||
minute = second * 60, | ||
hour = minute * 60, | ||
day = hour * 24; | ||
(() => { | ||
const second = 1000; | ||
const minute = second * 60; | ||
const hour = minute * 60; | ||
const day = hour * 24; | ||
|
||
//I'm adding this section so I don't have to keep updating this pen every year :-) | ||
//remove this if you don't need it | ||
let today = new Date(), | ||
dd = String(today.getDate()).padStart(2, "0"), | ||
mm = String(today.getMonth() + 1).padStart(2, "0"), | ||
yyyy = today.getFullYear(), | ||
dayMonth = "04/13/", | ||
eventTime = "April 13, 2024 11:00:00 GMT+0530"; | ||
let today = new Date(); | ||
let dd = String(today.getDate()).padStart(2, "0"); | ||
let mm = String(today.getMonth() + 1).padStart(2, "0"); | ||
let yyyy = today.getFullYear(); | ||
let dayMonth = "04/13/"; | ||
let eventTime = "April 13, 2024 11:00:00 GMT+0530"; | ||
|
||
today = mm + "/" + dd + "/" + yyyy; | ||
today = `${mm}/${dd}/${yyyy}`; | ||
//end | ||
|
||
const countDown = new Date(eventTime).getTime(), | ||
x = setInterval(function () { | ||
const now = new Date().getTime(), | ||
distance = countDown - now; | ||
const countDown = new Date(eventTime).getTime(); | ||
const x = setInterval(() => { | ||
const now = new Date().getTime(); | ||
const distance = countDown - now; | ||
|
||
(document.getElementById("days").innerText = Math.floor( | ||
distance / day | ||
)), | ||
(document.getElementById("hours").innerText = Math.floor( | ||
(distance % day) / hour | ||
)), | ||
(document.getElementById("minutes").innerText = Math.floor( | ||
(distance % hour) / minute | ||
)), | ||
(document.getElementById("seconds").innerText = Math.floor( | ||
(distance % minute) / second | ||
)); | ||
|
||
(document.getElementById("days1").innerText = Math.floor( | ||
distance / day | ||
)), | ||
(document.getElementById("hours1").innerText = Math.floor( | ||
(distance % day) / hour | ||
)), | ||
(document.getElementById("minutes1").innerText = Math.floor( | ||
(distance % hour) / minute | ||
)), | ||
(document.getElementById("seconds1").innerText = Math.floor( | ||
(distance % minute) / second | ||
)); | ||
const days = String(Math.floor(distance / day)).padStart(2, "0"); | ||
const hours = String(Math.floor((distance % day) / hour)).padStart( | ||
2, | ||
"0" | ||
); | ||
const minutes = String(Math.floor((distance % hour) / minute)).padStart( | ||
2, | ||
"0" | ||
); | ||
const seconds = String( | ||
Math.floor((distance % minute) / second) | ||
).padStart(2, "0"); | ||
|
||
if (distance < 0) { | ||
document.getElementById("headline").innerText = | ||
"It's my birthday!"; | ||
document.getElementById("countdown").style.display = "none"; | ||
document.getElementById("content").style.display = "block"; | ||
clearInterval(x); | ||
} | ||
//seconds | ||
}, 0); | ||
document.getElementById("days").innerText = days; | ||
document.getElementById("hours").innerText = hours; | ||
document.getElementById("minutes").innerText = minutes; | ||
document.getElementById("seconds").innerText = seconds; | ||
|
||
document.getElementById("days1").innerText = days; | ||
document.getElementById("hours1").innerText = hours; | ||
document.getElementById("minutes1").innerText = minutes; | ||
document.getElementById("seconds1").innerText = seconds; | ||
|
||
if (distance < 0) { | ||
document.getElementById("headline").innerText = "It's my birthday!"; | ||
document.getElementById("countdown").style.display = "none"; | ||
document.getElementById("content").style.display = "block"; | ||
clearInterval(x); | ||
} | ||
//seconds | ||
}, 0); | ||
})(); |