Last active
December 27, 2015 13:29
-
-
Save n1ghtmare/7334098 to your computer and use it in GitHub Desktop.
moment.js countdown prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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