How to display the current time in HTML <p> tag (paragraph) with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>

<p id="pid"></p>

<script> 
var interval = setInterval(function(){ ShowTime() }, 1000);

function ShowTime() {
    var dt = new Date();
    var tm = dt.toLocaleTimeString();
    document.getElementById("pid").innerHTML = tm;
}


/*
run:
 
09:16:05
 
*/
</script>

</body>
</html>

 



answered May 3, 2017 by avibootz
edited May 3, 2017 by avibootz

Related questions

1 answer 221 views
1 answer 243 views
2 answers 269 views
269 views asked Dec 1, 2018 by avibootz
1 answer 259 views
...