I’m not overly familiar with javascript, but I’ve played around with enough to get this far with a script I found on this site.
<script>
function updateClock ( ) {
var sd = Math.round(new Date().getTime() * 0.0000067322371075102 );
document.getElementById("stardate").firstChild.nodeValue = sd;
}
</script>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
<span id="stardate"> </span>
</body>
The output is a number that is very close to the stardate calculation used currently in Star Trek Online. However, that number should have the decimal point move left 2 places. Adding and removing zeros in my equation will shorten or extend my count, but I need a decimal, and I’m completely unaware how I can get this to happen.
Does anyone have an idea for me?
Either:
Or:
Some advice:
It’s not a good idea to mix JavaScript in your HTML; instead of putting JavaScript in HTML attributes programmatically attach your handlers. For example:
setIntervalcan take a function value as a reference. Instead of writing:…better to do this: