<div id="clock"></div>
<a href="javascript:void(0)" onclick="startTime()" id="time" class="show-time">show time</a>
<script type="text/javascript">
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('clock').innerHTML = h+":"+m+":"+s;
var t = setTimeout(function(){startTime()},500);
}

function checkTime(i) {
if (i<10) {i = "0" + i};  // add zero in front of numbers < 10
return i;
}
</script>


2 Comments

capecodcynic · April 17, 2016 at 9:42 pm

How do i color the output in this clock? i have a dark photo background and need to change the black to a lighter color. not sure where the output code would go, or what styles are available, e.g., engraved or embossed, l to r scroll, etc.

i cant find a tutorial to show how to manipulate the output results in a browser.

any help will be appreciated

    Sushant Vishwas · April 19, 2016 at 12:48 pm

    Like for green:
    inside your div give the style=”color:green;”

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *