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

135
Views
el temporizador de cuenta regresiva no aparece

Estaba tratando de crear una cuenta regresiva con php y js. Estoy aprendiendo js y php en este momento, así que quería probar y combinar estos dos para hacer una cuenta regresiva en la que se incluyen días, horas, minutos y segundos. el resultado de este código solo me dice hasta cuándo se ejecuta, pero no cuánto tiempo queda, por lo que la cuenta regresiva en sí no funciona. ¿Alguien puede ayudar?

 <?php $date = date('2022-02-26'); $time = date('23:59:59'); $date_today = $date . ' ' . $time; echo "it will run till" .$date_today; ?> <script type="text/javascript"> //set the date we are counting to var count_id = "<?php echo $date_today; ?>"; var countDownDate = new Date(count_id).getTime(); //update countdown every second var x = setInterval(function(){ //get today's date and time var now = new date().getTime(); //find the distance between now and countdown date var distance = countDownDate - now; //time calculations for days, hours, minutes and seconds var days = Math.floor(distance/(1000 * 60 * 60 * 24)); var hours = Math.floor((distance%(1000*60*60*24))/(1000*60*60)); var minutes = Math.floor((distance%(1000*60*60))/(1000*60)); var seconds = Math.floor((distance%(1000*60))/1000); // output the results in an elemtwith id="demo" document.getElementById("demo").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s "; // If the countdown over, write some text if(distance<0){ clearInterval(x); document.getElementById("demo").innerHTML="Expired" } },1000); </script><?php echo '<p id="demo" style="font-size:30px;"></p>'; ?>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

var now = new date().getTime();

error de ortografía, debería ser

 var now = new Date().getTime();

y ahora funciona

about 4 years ago · Juan Pablo Isaza Report
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!