Skip to content

Instantly share code, notes, and snippets.

@jorgejr568
Created November 3, 2018 16: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 jorgejr568/b6770ee876fac6f5810d2e95dd323e4c to your computer and use it in GitHub Desktop.
Save jorgejr568/b6770ee876fac6f5810d2e95dd323e4c to your computer and use it in GitHub Desktop.
Relógio JS
<html>
<head>
<style>
h1{
text-align: center;
font-family: "Helvetica",sans-serif;
font-size: 50px;
}
</style>
</head>
<body>
<h1></h1>
</body>
<script>
function zeroNaFrente(n){
if(n < 10){
return "0" + n;
}
return n;
}
function carregaHora(){
let data = new Date();
return zeroNaFrente(data.getHours()) + ":" +
zeroNaFrente(data.getMinutes()) + ":"+
zeroNaFrente(data.getSeconds());
}
setInterval(function(){
document.querySelector('h1').innerHTML = carregaHora();
},1000);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment