mirror of
https://github.com/hexahigh/080609.git
synced 2025-12-11 19:55:06 +01:00
a
This commit is contained in:
parent
b63c362955
commit
83dd231823
@ -10,6 +10,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<p>If you were born on the 8th of June 2009 you would be</p>
|
||||
<p><h3 id="age"></h3><p>Years old</p></p>
|
||||
<h3 id="age"></h3>
|
||||
<p>And you birthday would be in</p>
|
||||
<div id="countdown"></div>
|
||||
</body>
|
||||
</html>
|
||||
20
index.js
20
index.js
@ -5,4 +5,22 @@ function calculateYearsSince(date) {
|
||||
}
|
||||
|
||||
const myDate = new Date('2009-08-06');
|
||||
document.getElementById("age").innerText = calculateYearsSince(myDate);
|
||||
document.getElementById("age").innerText = calculateYearsSince(myDate) + " Years old";
|
||||
|
||||
|
||||
function countdownTimer() {
|
||||
const now = new Date().getTime();
|
||||
const nextYear = new Date("2023-06-08").getTime();
|
||||
const timeRemaining = nextYear - now;
|
||||
|
||||
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
|
||||
const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
|
||||
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
|
||||
|
||||
const countdownDiv = document.getElementById("countdown");
|
||||
countdownDiv.innerHTML = days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds";
|
||||
}
|
||||
|
||||
// Call the countdownTimer() function every second using setInterval
|
||||
setInterval(countdownTimer, 1000);
|
||||
Loading…
x
Reference in New Issue
Block a user