Skip to content

Instantly share code, notes, and snippets.

@n1ghtmare
Last active December 27, 2015 13:29
Show Gist options
  • Save n1ghtmare/7334098 to your computer and use it in GitHub Desktop.
Save n1ghtmare/7334098 to your computer and use it in GitHub Desktop.
moment.js countdown prototype
var countdown = function(end) {
var start = moment();
var d = end.diff(start);
var dur = moment.duration(d);
var days = dur.days();
var hours = dur.hours();
var minutes = dur.minutes();
var seconds = dur.seconds();
$("#countdown").html(days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds ");
};
$(function(){
var e = moment().add("days", 22);
countdown(e);
setInterval(function() {
countdown(e);
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment