Casa > H > How To Make A Basic Html Count-Up Timer

How to make a basic HTML count-up timer

HTML is only a markup language you can’t make counter with it.

You can use javascript for this. Here’s the code you might be looking for.

  1. var countDownDate = localStorage.getItem('startDate'); 
  2. if (countDownDate) { 
  3. countDownDate = new Date(countDownDate); 
  4. } else { 
  5. countDownDate = new Date(); 
  6. localStorage.setItem('startDate', countDownDate); 
  7. // Update the count down every 1 second 
  8. var x = setInterval(function() { 
  9.  
  10. // Get todays date and time 
  11. var now = new Date().getTime(); 
  12.  
  13. // Find the distance between now an the count down date 
  14. var distance = now - countDownDate.getTime(); 
  15.  
  16. // Time calculations for days, hours, minutes and seconds 
  17. var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 
  18. var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 
  19. var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 
  20. var seconds = Math.floor((distance % (1000 * 60)) / 1000); 
  21.  
  22. // Output the result in an element with id="demo" 
  23. document.getElementById("demo").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s "; 
  24. }, 1000); 
  25.  
  26.  

De Beverle Lapete

O que posso colocar atrás da minha grelha para evitar que a minha casa fique quente? :: O que significa largura de banda de 20 MHz?