This commit is contained in:
Boof 2023-05-31 13:43:06 +02:00 committed by GitHub
parent aa23f41fe9
commit 735f1685ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);