date du jour heure js code example
Example: get local time second javascript heure temps réel
<body>
<p>Il est <span id="time"></span>.</p>
<button id="stop">Stop time</button>
<script>
let hour = document.getElementById("time");
let stop = document.getElementById("stop");
let realTime = setInterval(clock, 1000);
function clock(){
let d = new Date();
hour.innerHTML = d.toLocaleTimeString();
}
stop.addEventListener ("click", arret);
function arret() {
clearInterval(realTime);
}
</script>
</body>