Skip to content

Instantly share code, notes, and snippets.

@shamdasani
Last active November 5, 2016 23:11
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 shamdasani/ba381da14bf2fc64fc0c91993a560c21 to your computer and use it in GitHub Desktop.
Save shamdasani/ba381da14bf2fc64fc0c91993a560c21 to your computer and use it in GitHub Desktop.
function moveHands() {
with(new Date()) {
h = 30 * (getHours() % 12 + getMinutes() / 60); // 30 degrees hour
m = 6 * getMinutes(); // 6 degrees every minute
s = 6 * getSeconds(); // 6 degrees every second
document.getElementById('seconds').style.cssText = "-webkit-transform:rotate(" + s + "deg);"; // setting the rotate CSS attribute to those degree values
document.getElementById('minutes').style.cssText = "-webkit-transform:rotate(" + m + "deg);";
document.getElementById('hours').style.cssText = "-webkit-transform:rotate(" + h + "deg);";
setTimeout(moveHands, 1000); // calling the function every second
}
}
window.onload = moveHands; // making sure the function starts on load of webpage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment