You can refer this link
http://www.w3schools.com/js/js_timing.asp
Here is the demo
http://www.w3schools.com/js/tryit.asp?filename=tryjs_setinterval2
You can also stop the time refer this
http://www.w3schools.com/js/tryit.asp?filename=tryjs_setinterval3
This will stop after 30 minutes after the start quiz button click.
<html>
<body>
<p>
A script on this page starts this clock:</p>
<p id="demo">
</p>
<button onclick="myFunction()">
Start Quize</button>
<script>
var myVar = setInterval(function () { myTimer() }, 1000);
function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}
function myFunction() {
// 1800000 is 30 minutes
setTimeout(function () { clearInterval(myVar) }, 1800000);
}
</script>
</body>
</html>
Demo
Thank You.