Skip to content

Instantly share code, notes, and snippets.

@chenzx
Last active December 11, 2015 02:18
Show Gist options
  • Save chenzx/4529313 to your computer and use it in GitHub Desktop.
Save chenzx/4529313 to your computer and use it in GitHub Desktop.
<body>
<style>
#c{
position: absolute;
left: 1200px;
top: 100px;
width: 80px;
height: 25px;
color: blue;
border: 2px solid red;
}
</style>
<div id='c'/>
<script>
var c=document.getElementById('c');
setInterval(function(){
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getSeconds();
c.innerText = align2(hh)+':'+align2(mm)+':'+align2(ss);
function align2(num){return num<10?'0'+num:''+num;}
}, 1000);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment