im trying to countdown from the 2 dates that i have and i have the following code :
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" />
the result that i get with the following code above is 73 Months 2190 Days left and i want something like this 73 Months 29 Days left. thanks in advance