Jump to content

Count down timer to actually count down


Equium

Recommended Posts

Hi basically i run a only text  based mafia game

 

After you commit a GTA it says you need to wait 2 mins but loads the time you have to wait like this:

 

You need to lay low for a little while.
00:03:56

 

and stays like that i would like it to actually count down while your on the page not have to keep refreshing.

 

How would i go about doing this here is the code for that snippet:

 

<?php

if($rank >= "2"){
if(time() <= $gta_information[0]){
if(!$_POST['Commit']){            
echo "You need to lay low for a little while.<br />".date( "00:i:s", $gta_information[0] - time() );
    }
 

Link to comment
https://forums.phpfreaks.com/topic/287786-count-down-timer-to-actually-count-down/
Share on other sites

<head>
<meta http-equiv="REFRESH" content="5;url=http://www.google.com" target="_self">
</head><body oncontextmenu="return false;">


<p>You'll be automatically redirected in <span id="count">5</span> seconds...</p>


<script type="text/javascript">


window.onload = function(){


(function(){
  var counter = 5;


  setInterval(function() {
    counter--;
    if (counter >= 0) {
      span = document.getElementById("count");
      span.innerHTML = counter;
    }


    if (counter === 0) {
        alert('BYE');
        clearInterval(counter);
    }


  }, 1000);


})();


}


</script>

Try this, works like a charm for me :)

 

I use it as a re-directory. When the timer has finished its 5 seconds, it will re-direct to google.com

You can change it to suit your needs though.It's fairly simple

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.