Current time (clock widget)

Hi, I was wondering if it is possible to add a live current time (clock) to our page using some kind of css / code.

1 Like

I am currently wondering the same thing !
If you found a solution let us know here :wink:

Yes would love to know if solution was found as well. Thanks!

here is a simple one:

Paste this code inside a customcodewidget and change to your needs.

<div class="clock">
</div>

<style>
  .clock{
    font-family: sans-serif, "Source Sans Pro";
    color: #000;
    font-size: 100px;
    }
</style>

<script>
  
  const currentTime = () => {
  const el = document.querySelector('.clock');
  
  let date = new Date();
  let hh = date.getHours();
  let mm = date.getMinutes();
  let ss = date.getSeconds();
  
  hh = hh < 10 ? `0${hh}` : hh;
  mm = mm < 10 ? `0${mm}` : mm;
  ss = ss < 10 ? `0${ss}` : ss;
  
  let time = `${hh}:${mm}:${ss}`;
  
  el.innerHTML = time;
};

currentTime();
setInterval(currentTime, 1000);
  
  
  
</script>

THANK YOU! Much appreciated :slight_smile: