HTML/Compte à rebours

De Kono Phil Ceci est la tagline
Aller à : navigation, rechercher
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <xmeta http-equiv="refresh" content="5">	
    <title>Compte à rebours</title>
	<style>
	  h1 {background: grey; color: white; padding: .25em;}
	  footer {background: grey; color: white; margin: .5em 0; padding: 10px 5px; font-size: 1.5em;}
	  #compte_a_rebours {font-size: 2em;}
	</style>
  </head>
<body>
  <h1>Compte à rebours</h1>
  <div id="compte_a_rebours"></div>
  <footer>
    <p>Compte à rebours</p>
  </footer>
  <script type="text/javascript">
    var compte_a_rebours = document.getElementById("compte_a_rebours");
	function Rebour() {
      var datedujour = new Date();
      var datecible = new Date ("aug 7 17:00:00 2020");
      var sec = (datecible - datedujour) / 1000;
      var n = 24 * 3600;
      if (sec > 0) {
	    nbsec = Math.floor(sec);
        j = Math.floor (sec / n);
        h = Math.floor ((sec - (j * n)) / 3600);
        mn = Math.floor ((sec - ((j * n + h * 3600))) / 60);
        sec = Math.floor (sec - ((j * n + h * 3600 + mn * 60)));
        compte_a_rebours.innerHTML = "Temps restant : " + j +" j "+ h +" h "+ mn +" min "+ sec + " s ==> " + nbsec + " s";
        //window.status = "Temps restant avant le jour J : " + j +" j "+ h +" h "+ mn +" min "+ sec + " s ==> " + nbsec;
        }
      tRebour=setTimeout ("Rebour();", 1000);
    }
Rebour();
</script>
</body>
</html>