Adding a clock to your wix website

Hi Pax,

If you just whant to display it like
hours:minuts:seconds (08:35:15)
and you want to show the clock ticking evry second
Then here is some small code and no canvas needed .

The only thing you should do is add a text element named txtClock.

function clock(){
    let newdate = new Date()
    let settime = newdate.getHours() + ":" + newdate.getMinutes() + ":" + newdate.getSeconds()
    $w("#txtClock").text = settime
}

$w.onReady(async function () {
    setInterval(function(){clock()},1000)
    })

This won’t be a visual round clock.

Kind regards,
Kristof.

1 Like