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 304 views
1 answer 343 views
2 answers 379 views
379 views asked Dec 1, 2018 by avibootz
1 answer 361 views
...