Created
January 20, 2022 20:51
-
-
Save nijatmursali/893c234ee8e1443bca4460cdbbcdb710 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<meta charset="utf-8" /> | |
<title>Clock</title> | |
</head> | |
<body> | |
<div id="time">00:00:00</div> | |
</body> | |
<script type="text/javascript"> | |
function start() { | |
let time = new Date(); | |
let hours = time.getHours(); | |
let mins = time.getMinutes(); | |
let seconds = time.getSeconds(); | |
if (seconds.toString().length == 1) { | |
seconds = "0" + seconds.toString(); | |
} | |
if (mins.toString().length == 1) { | |
mins = "0" + mins.toString(); | |
} | |
if (hours.toString().length == 1) { | |
hours = "0" + hours.toString(); | |
} | |
document.getElementById("time").innerHTML = hours.toString() + ":" + mins.toString() + ":" + seconds.toString(); | |
setTimeout(() => { | |
start() | |
}, 1); | |
} | |
start(); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment