Last active
November 30, 2016 19:05
-
-
Save SBachvarov/197153b1a524ed6344577cd194ead3fc to your computer and use it in GitHub Desktop.
Real time changing clock with JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
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('time').innerHTML = | |
h + ":" + m + ":" + s; | |
var t = setTimeout(startTime, 500); | |
return h; | |
} | |
function checkTime(i) { | |
if (i <10) {i = "0" + i} | |
return i; | |
} | |
</script> | |
//In HTML | |
... | |
<div id="somid">Some content</div> | |
<script type="text/javascript"> | |
oQuickReply.swap('somid'); | |
</script> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment