How to show a clock running the hundredth of seconds

Asked

Viewed 526 times

2

I need to create a game that looks like a bingo game. He has to show a clock running the hundredth of seconds .

Each game member receives a card with multiple numbers from 0 to 99 and he has the option to try to stop the clock at a number he has on his card.

How do I run the hundredths in php and stop when I press a button?

To run a Clock with Hours, Minutes and Seconds, I got:

<script language="JavaScript">
<!--
function showtime()
{ setTimeout("showtime();",1000);
callerdate.setTime(callerdate.getTime()+1000);
var hh = String(callerdate.getHours());
var mm = String(callerdate.getMinutes());
var ss = String(callerdate.getSeconds());

document.clock.face.value = 
((hh < 10) ? " " : "") + hh +
((mm < 10) ? ":0" : ":") + mm +
((ss < 10) ? ":0" : ":") + ss;

}
callerdate=new Date(<?php echo date("Y,m,d,H,i,s");?>);
//-->
</script>
  • Hey, buddy, post your html so I can give you a better answer.

1 answer

1

I changed the code to display the milliseconds on the clock:

   <script language="JavaScript">
callerdate=new Date(2016,10,27,11,43,14);

function showtime()
{	setTimeout("showtime();",10);
callerdate.setTime(callerdate.getTime()+ 10 );
var hh = String(callerdate.getHours());
var mm = String(callerdate.getMinutes());
var ss = String(callerdate.getSeconds());
var n = callerdate.getMilliseconds();
document.clock.face.value = 
((hh < 10) ? " " : "") + hh +
((mm < 10) ? ":0" : ":") + mm +
((ss < 10) ? ":0" : ":") + ss +
":" + n;
}

function getTime(){
//clearTimeout(callerdate);
  var hora = document.clock.face.value;
document.clock.result.value = hora;
}


</script>
<body onLoad="showtime()">
<form name="clock">
<input type="text" name="face" id="clock" value="" size=15>
<input type="text" name="result" id="result" value="" size=15>
</form>

<div id="clockButton"  onclick="getTime()">Pega!</div>
</body>

  • So friend, this is the link where the clock already works

  • So friend, this is the link where the clock already works

  • http://www.supplementsweb.site88.net/relogio.php I need to know how to run the Hundredth of seconds. the player will try to stop the number he needs by pressing a boot..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.