stackoverflow-240842

https://pt.stackoverflow.com/questions/240842/contagem-regressiva-incluir-m%c3%aas

HTML

<script src="https://momentjs.com/downloads/moment.js"></script>
<body>
  <div id="div">

  </div>
</body>

JavaScript

var getCountDownBetween = function () {
	var from = moment().format("YYYY-MM-DDTHH:mm:ss");
  var to = moment('2018-10-06T13:00:00');
  // Find the distance between now an the count down date
  var distance = moment.duration(to.diff(from));
  // Time calculations for days, hours, minutes and seconds
  return {
  	months: distance.months(),
  	days : distance.days(),
  	hours : distance.hours(),
  	minutes : distance.minutes(),
  	seconds : distance.seconds(),
    toString: function() {
    	return this.months + 'mo ' 
      			+ this.days + "d " 
            + this.hours + "h " 
            + this.minutes + "m " 
            + this.seconds + "s ";
    }
	};
}

//Test functions

var appendHTML = function (str) {
	document.getElementById('div').innerHTML += '</br>' + str;
}

//Test

appendHTML(getCountDownBetween());