Skip to content

Instantly share code, notes, and snippets.

@timrwood
Created June 22, 2012 15:58
Show Gist options
  • Save timrwood/2973677 to your computer and use it in GitHub Desktop.
Save timrwood/2973677 to your computer and use it in GitHub Desktop.
Formatted diff
function pad(input) {
if (input < 10) {
return '0' + input;
}
return input;
}
moment.duration.fn.formatCountdown = function() {
var output = [
pad(this.years()),
pad(this.months()),
pad(this.days()),
pad(this.hours()),
pad(this.minutes()),
pad(this.seconds())
].join(':');
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment