Skip to content

Instantly share code, notes, and snippets.

@starlilyth
Last active January 2, 2023 23:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starlilyth/5113036a6a7fbe51ea0861254c822010 to your computer and use it in GitHub Desktop.
Save starlilyth/5113036a6a7fbe51ea0861254c822010 to your computer and use it in GitHub Desktop.
Current Stardate webpage
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Current Stardate</title>
<style>
body {
margin: 0px;
padding-top: 25%;
color: white;
background-color: darkblue;
font-family: Arial, sans-serif;
}
p {
text-align: center;
font-size: small;
}
.datebox {
display: flex;
justify-content: center;
align-items: center;
height: 20vh;
font-size: 10vw;
}
</style>
</head>
<body>
<div class="datebox">
<h1 id="stardate"></h1>
</div>
<p>Current Stardate</p>
<script>
// math from https://trekguide.com/Stardates.htm
function starDateNow (timeNow) {
var StardateOriginToday = new Date("July 15, 1987 00:00:00");
var stardateToday = timeNow - StardateOriginToday.getTime();
stardateToday = stardateToday / (1000 * 60 * 60 * 24 * 0.036525);
stardateToday = Math.floor(stardateToday + 410000);
stardateToday = stardateToday / 10
document.getElementById("stardate").innerHTML = stardateToday;
}
window.onload = starDateNow (Date.now());
setInterval( function () {
starDateNow (Date.now());
}, 60 * 1000);
</script>
</body>
</html>
@melt7777
Copy link

melt7777 commented Jan 2, 2023

Such easy to read code lily! Thanks for sharing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment