Created
September 15, 2021 07:55
-
-
Save ruyut/074ee7cc3515e63e18864681a2e6471c to your computer and use it in GitHub Desktop.
JavaScript 自動更新的時鐘
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
<p id="clock"></p> | |
<script> | |
const clock = function () { | |
let getDate = new Date(); | |
document.getElementById("clock").innerHTML = getDate.toLocaleTimeString( | |
[], | |
{ hour: "2-digit", minute: "2-digit", second: "2-digit" } | |
); | |
}; | |
setInterval(function () { | |
clock(); | |
}, 1000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment