Add counter

This commit is contained in:
Octo Andri 2022-04-17 17:19:29 +00:00
parent 81bbeb5bfb
commit c9ad067ef9
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,20 @@
// All Unix time values are in milliseconds (ms)
const UnixDay = 86400000;
const UnixYear = 31536000000;
const BirthTime = 1082713500000;
function UnixTime() {
let DateNow = Date.now();
let TimeSinceBirth = DateNow - BirthTime;
let YearsSinceBirth = TimeSinceBirth / UnixYear;
let LeapYears = ~~(YearsSinceBirth / 4);
return DateNow - UnixDay*LeapYears;
}
function UnixAgeNow() {
return UnixTime() - BirthTime;
}
function UnixToYears() {
return UnixAgeNow() / UnixYear;
}

View File

@ -13,6 +13,7 @@
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">
<link href="Assets/CSS/Dark.css" rel="stylesheet">
<script src="Assets/JS/RandomGIF.js"></script>
<script src="Assets/JS/CurrentAge.js"></script>
</head>
<body>
@ -25,9 +26,20 @@
<h4><a href="FumoPrisms/">Fumo Prisms (!)</a></h4>
<br>
<h4><a href="WebPinBoard/">My WebPinBoard</a></h4>
<br>
</p>
<div>
<p id="CurrentAge"></p>
<noscript><p>There should be a ticking clock here, but your browser isn't loading the JavaScript.</p></noscript>
</div>
<br><br><br>
</div>
<script>
var CurrentAgeText = document.getElementById("CurrentAge").textContent;
const CurrentAgeRefresh = 50;
setInterval(
function() {CurrentAgeText = "Currently" + UnixToYears() + ".."},
CurrentAgeRefresh);
</script>
</body>
</html>