Estoy tratando de hacer una cuenta regresiva desde las 2 fechas que tengo y tengo el siguiente código:
jquery
var end_date= $('#end_date').val() var start_date= $('#start_date').val() var countDownDate = end_date* 1000; var now = start_date* 1000; var x = setInterval(function() { now = now + 1000; var distance = countDownDate - now; var months = Math.floor( distance / (1000 * 60 * 60 * 24 * 30 ) ); var days = Math.floor(distance / (1000 * 60 * 60 * 24)); $("#demo").html(months+ " M " + days + " D " ); if (distance < 0) { clearInterval(x); $("demo").css("background-color", "red") } }, 1000);HTML
<p id="demo"></p> <input type="hidden" id="start_date" value="1509728400" /> <input type="hidden" id="end_date" value="1699030800" />el resultado que obtengo con el siguiente código anterior es 73 Meses 2190 Días restantes y quiero algo como esto 73 Meses 29 Días restantes. gracias de antemano