Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created January 5, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/4967bcfb0b2497c96c521ece99ef8909 to your computer and use it in GitHub Desktop.
Save ssaurel/4967bcfb0b2497c96c521ece99ef8909 to your computer and use it in GitHub Desktop.
hexaTime function for Hexadecimal Color Clock on the SSaurel's Blog
function hexaTime() {
var date = new Date();
// we convert in the 0 .. 255 range
var seconds = parseInt(date.getSeconds() * 255 / 59);
var minutes = parseInt(date.getMinutes() * 255 / 59);
var hours = parseInt(date.getHours() * 255 / 23);
return "#" + toHex(hours) + toHex(minutes) + toHex(seconds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment