This commit is contained in:
Boof 2023-06-01 08:08:32 +02:00 committed by GitHub
parent b7ac76d615
commit 7b9add13a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -13,7 +13,10 @@
<body>
<div style="text-align: center;">
<p>If you were born on the 8th of June 2009 you would be</p>
<h3 id="age"></h3>
<h3 id="ageYears"></h3>
<h3 id="ageDays"></h3>
<h3 id="ageHours"></h3>
<h3 id="ageMinutes"></h3>
<p>And your birthday would be in</p>
<div id="countdown"></div>
</div>

View File

@ -4,10 +4,23 @@ function calculateYearsSince() {
const diffInMs = Date.now() - myDate.getTime();
const diffInYears = diffInMs / (1000 * 60 * 60 * 24 * 365.25);
const days = Math.floor(diffInMs / (1000 * 60 * 60 * 24));
const hours = Math.floor((diffInMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const hours = Math.floor(hoursSince())
//const hours = Math.floor((diffInMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((diffInMs % (1000 * 60 * 60)) / (1000 * 60));
document.getElementById("age").innerText = Math.floor(diffInYears) + " years, " + days + " days, " + hours + " hours and " + minutes + " minutes"
document.getElementById("ageYears").innerText = Math.floor(diffInYears) + " years"
document.getElementById("ageDays").innerText = days + " days"
document.getElementById("ageHours").innerText = hours + " hours"
document.getElementById("ageMinutes").innerText = minutes + " minutes"
}
function hoursSince() {
const myDate = new Date('2009-06-08');
const now = new Date();
const diff = now - myDate;
const hours = Math.floor(diff / 3.6e6);
return hours;
}
var year = 2023