Skip to content

Instantly share code, notes, and snippets.

@mmb
Created December 6, 2015 20:35
Show Gist options
  • Save mmb/71a6e8a0a1ebb97c502e to your computer and use it in GitHub Desktop.
Save mmb/71a6e8a0a1ebb97c502e to your computer and use it in GitHub Desktop.
javascript current time in beats
<h1 id="time"></h1>
<script>
function toBeats(date) {
return ((date.getTime() / 1000.0) + 3600) % 86400 / 86.4;
}
function formatTime(date) {
return (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes();
}
function update() {
var d = new Date();
document.getElementById("time").innerHTML = formatTime(d) + " / @" + Math.floor(toBeats(d));
}
setInterval(update, 1000);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment