Hi. I have a function in my game that you only can use every 2 min. So I have this code
$next = strtotime ("+2 minutes");
This function to check if 2 minutes has passed:
if(time() <= $next){
Here I find the time when you can do the function again:
date( "00:i:s", $next - time())
What I need is the number of seconds until you can launch the function. I use this javascript to countdown:
$wait = $next - time();
<form name="counter"><input type="text" size="8" name="d2"></form>
<script>
var milisec=0
var seconds={$wait}
document.counter.d2.value='{$wait}'
function display(){
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
else
milisec-=1
document.counter.d2.value=seconds+"."+milisec
setTimeout("display()",100)
}
display()
Does $next - time()
represent the correct number of seconds? It doesn't seem to be correct and that is a little important..