Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
jquery countdown months and days

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!