Skip to content

Instantly share code, notes, and snippets.

@drunkensouljah
Created November 8, 2015 21:12
Show Gist options
  • Select an option

  • Save drunkensouljah/6bab0c9b3c152f762f81 to your computer and use it in GitHub Desktop.

Select an option

Save drunkensouljah/6bab0c9b3c152f762f81 to your computer and use it in GitHub Desktop.
Uhrzeit auf homepage ausgeben (Javascript)
<!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