Skip to content

Instantly share code, notes, and snippets.

@pvorb
Created March 21, 2012 02: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 pvorb/2143717 to your computer and use it in GitHub Desktop.
Save pvorb/2143717 to your computer and use it in GitHub Desktop.
Log the time on every second
setInterval(function () {
console.log(getTime(new Date()));
}, 1000);
function pad(n) {
return n < 10 ? '0'+n : n;
}
function getTime(dt) {
return pad(dt.getHours())+':'+pad(dt.getMinutes())+':'+pad(dt.getSeconds());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment