JSFiddle - React, Tailwind, and code Playground
by amindunited
HTML
<script src="https://rawgithub.com/moment/moment/develop/min/moment.min.js"></script>
<script>
/*
countdown.js v2.3.3 http://countdownjs.org
Copyright (c)2006-2012 Stephen M. McKamey.
Licensed under The MIT License.
*/
var module,countdown=function(r){function v(a,b){var c=a.getTime();a.setUTCMonth(a.getUTCMonth()+b);return Math.round((a.getTime()-c)/864E5)}function t(a){var b=a.getTime(),c=new Date(b);c.setUTCMonth(a.getUTCMonth()+1);return Math.round((c.getTime()-b)/864E5)}function f(a,b){return a+" "+(1===a?p[b]:q[b])}function n(){}function l(a,b,c,g,x,d){0<=a[c]&&(b+=a[c],delete a[c]);b/=x;if(1>=b+1)return 0;if(0<=a[g]){a[g]=+(a[g]+b).toFixed(d);switch(g){case "seconds":if(60!==a.seconds||isNaN(a.minutes))break;
a.minutes++;a.seconds=0;case "minutes":if(60!==a.minutes||isNaN(a.hours))break;a.hours++;a.minutes=0;case "hours":if(24!==a.hours||isNaN(a.days))break;a.days++;a.hours=0;case "days":if(7!==a.days||isNaN(a.weeks))break;a.weeks++;a.days=0;case "weeks":if(a.weeks!==t(a.refMonth)/7||isNaN(a.months))break;a.months++;a.weeks=0;case "months":if(12!==a.months||isNaN(a.years))break;a.years++;a.months=0;case "years":if(10!==a.years||isNaN(a.decades))break;a.decades++;a.years=0;case "decades":if(10!==a.decades||
isNaN(a.centuries))break;a.centuries++;a.decades=0;case "centuries":if(10!==a.centuries||isNaN(a.millennia))break;a.millennia++;a.centuries=0}return 0}return b}function w(a,b,c,g,d,k){a.start=b;a.end=c;a.units=g;a.value=c.getTime()-b.getTime();if(0>a.value){var f=c;c=b;b=f}a.refMonth=new Date(b.getFullYear(),b.getMonth(),15);try{a.millennia=0;a.centuries=0;a.decades=0;a.years=c.getUTCFullYear()-b.getUTCFullYear();a.months=c.getUTCMonth()-b.getUTCMonth();a.weeks=0;a.days=c.getUTCDate()-b.getUTCDate();
a.hours=c.getUTCHours()-b.getUTCHours();a.minutes=c.getUTCMinutes()-b.getUTCMinutes();a.seconds=c.getUTCSeconds()-b.getUTCSeconds();a.milliseconds=c.getUTCMilliseconds()-b.getUTCMilliseconds();var...
JavaScript
moment.lang('en', {
relativeTime : {
future: "in %s",
past: "%s ago",
s: "s",
m: "m",
mm: "%d m",
h: "h",
hh: "%d h",
d: "d",
dd: "%d d",
M: "m",
MM: "%d months",
y: "a year",
yy: "%d years"
}
});
$(function(){
var localTime = moment();
var eventTime = moment("2014-02-19T12:20:00+11:00");
var timeRemaining = localTime.countdown(eventTime,
countdown.MONTHS | countdown.DAYS | countdown.MINUTES | countdown.SECONDS
).toString();
console.log("timeremaining ", timeRemaining);
//timeRemaining = timeRemaining.replace(', and', '');
//var outputTime = timeRemaining.match(/(\d. seconds)?(\d. seconds)?/);
var seconds = timeRemaining.match(/^(\d.).*(\d.) seconds/);
console.log(seconds);
});