JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgithub.com/timrwood/moment/2.1.0/min/moment.min.js"></script>
JavaScript
var Countdown = function(endDate) {
this.endMoment = moment(endDate);
this.updateCountdown = function() {
var currentMoment, thisDiff;
currentMoment = moment();
thisDiff = (this.endMoment).diff(currentMoment, "seconds");
if (thisDiff > 0)
console.log(thisDiff);
else {
clearInterval(this.interval);
console.log("over");
}
}
this.interval = setInterval(this.updateCountdown(), 1000);
}
var countdown = new Countdown("January 1, 2014 00:00:00");