<!DOCTYPE html>
<html>
<body>
<p id="pid"></p>
<button onclick="StopTime()">Stop time</button>
<script>
var interval = setInterval(function(){ ShowTime() }, 1000);
function ShowTime() {
var dt = new Date();
var tm = dt.toLocaleTimeString();
document.getElementById("pid").innerHTML = tm;
}
function StopTime() {
clearInterval(interval);
}
/*
run:
09:51:08
*/
</script>
</body>
</html>