Created
November 8, 2015 21:12
-
-
Save drunkensouljah/6bab0c9b3c152f762f81 to your computer and use it in GitHub Desktop.
Uhrzeit auf homepage ausgeben (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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <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('txt').innerHTML = | |
| h + ":" + m + ":" + s; | |
| var t = setTimeout(startTime, 500); | |
| } | |
| function checkTime(i) { | |
| if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10 | |
| return i; | |
| } | |
| </script> | |
| </head> | |
| <body onload="startTime()"> | |
| <div id="txt"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment