added age in millieseconds

This commit is contained in:
Boof 2023-06-09 11:46:20 +02:00 committed by GitHub
parent 995fc1efe5
commit c7c534d418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -22,6 +22,7 @@
</div> </div>
<br> <br>
<div> <div>
<p>Want to know how old you are in millieseconds? <a href="ms.html">Go here</a></p>
<h3>What day was my birthday Jun 8, 2009?</h3> <h3>What day was my birthday Jun 8, 2009?</h3>
<p>June 8, 2009 was a Monday and it was the 159th day of the year 2009. It was the 23rd Monday of that year. The <p>June 8, 2009 was a Monday and it was the 159th day of the year 2009. It was the 23rd Monday of that year. The
next time you can reuse your old 2009 calendar will be in 2026. Both calendars will be exactly the same! next time you can reuse your old 2009 calendar will be in 2026. Both calendars will be exactly the same!

11
ms.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How old are you in millieseconds?</title>
</head>
<body>
<p id="number"></p>
</body>
</html>

15
ms.js Normal file
View File

@ -0,0 +1,15 @@
function calculateYearsSince() {
const myDate = new Date('2009-06-08');
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(hoursSince())
const minutes = Math.floor(diffInMs / 1000 / 60)
//const hours = Math.floor((diffInMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
//const minutes = Math.floor((diffInMs % (1000 * 60 * 60)) / (1000 * 60));
document.getElementById("number").innerText = diffInMs
}
setInterval(calculateYearsSince, 0.1)