mirror of
https://github.com/hexahigh/080609.git
synced 2025-12-11 19:55:06 +01:00
a
This commit is contained in:
parent
aa23f41fe9
commit
735f1685ea
13
index.js
13
index.js
@ -4,17 +4,26 @@ function calculateYearsSince(date) {
|
||||
return Math.floor(diffInYears);
|
||||
}
|
||||
|
||||
var year = 2023
|
||||
const myDate = new Date('2009-06-08');
|
||||
document.getElementById("age").innerText = calculateYearsSince(myDate) + " Years old";
|
||||
|
||||
const currentYear = new Date().getFullYear();
|
||||
const theDate = currentYear + "-06-08"
|
||||
const theDate = year + "-06-08"
|
||||
|
||||
function countdownTimer() {
|
||||
const now = new Date().getTime();
|
||||
const nextYear = new Date(theDate).getTime();
|
||||
const timeRemaining = nextYear - now;
|
||||
if (nextYear < 0) {
|
||||
year = year + 1
|
||||
countdownTimer()
|
||||
} else {
|
||||
countdown()
|
||||
}
|
||||
}
|
||||
|
||||
function countdown() {
|
||||
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));
|
||||
@ -25,4 +34,4 @@ function countdownTimer() {
|
||||
}
|
||||
|
||||
// Call the countdownTimer() function every second using setInterval
|
||||
setInterval(countdownTimer, 1000);
|
||||
setInterval(countdown, 1000);
|
||||
Loading…
x
Reference in New Issue
Block a user