Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<p>Add zeros and colons to display the universal time:</p>
<p id="demo"></p>
<script>
function addZero(i) {
  if (i < 10) {i = "0" + i}
  return i;
}
const d = new Date();
let h = addZero(d.getUTCHours());
let m = addZero(d.getUTCMinutes());
let s = addZero(d.getUTCSeconds());
let time = h + ":" + m + ":" + s;
document.getElementById("demo").innerHTML = time;
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_datetime_utc by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:39:07 GMT -->
</html>