Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created September 15, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/074ee7cc3515e63e18864681a2e6471c to your computer and use it in GitHub Desktop.
Save ruyut/074ee7cc3515e63e18864681a2e6471c to your computer and use it in GitHub Desktop.
JavaScript 自動更新的時鐘
<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