How to display a clock by rotating the hundredths of seconds

2

I need to create a game that looks like a bingo. It has to show a clock in the hundredths of a second.

Each member of the game receives a card with several numbers from 0 to 99 and he has the option of trying to stop the clock on a number he has in his card.

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

To run a Clock with Hours, Minutes and Seconds, I was able to:

<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>
    
asked by anonymous 19.10.2016 / 21:53

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>
    
19.10.2016 / 22:29