Skip to content

Instantly share code, notes, and snippets.

@mallendeo
Created February 9, 2014 18:24
Show Gist options
  • Save mallendeo/8903575 to your computer and use it in GitHub Desktop.
Save mallendeo/8903575 to your computer and use it in GitHub Desktop.
Simple Momentjs clock
// include jquery, momentjs
$(function () {
var m = moment();
var updateClock = function(){
var hour = m.hour() < 10 ? '0'+m.hour() : m.hour(),
minute = m.minute() < 10 ? '0'+m.minute() : m.minute();
$('#clock').text(hour+':'+minute);
}
updateClock();
setInterval(updateClock, 60000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment