How to add secounds.?

Can anyone say why secounds does not update. ?

var dato = new Date()

        timer = dato.getHours()
        min = dato.getMinutes()
        sek = dato.getSeconds()

        

        document.getElementById('time').innerHTML = (timer + ":" + min + ":" + sek);

        setTimeout(time, 1000)

You need to either create a function and move the code in it:

function nameOfYourFunction(){
    // code
}
setTimeout(nameOfYourFunction, 1000);

Or move whole code in setTimeout():

setTimeout(function(){
    // code
}, 1000);

EDIT: Also a tip: instead of updating the time every 1s, update it every 0.1s or less (because it takes some time to get and set time, so it will create offset)

The problem is that if I put it into a function nothing is displayed, so what are I am doing wrong. ?

You need to also put setTimeout(nameOfYourFunction, 1000); there (edit: NOT in the function, somwhere else). It will call the function.

Yes I seams to got this working, except that the clock stops after 2 sec. Do you know why. ?

function t() {

        var dato = new Date()

        timer = dato.getHours()
        min = dato.getMinutes()
        sek = dato.getSeconds()

        

        document.getElementById('time').innerHTML = (timer + ":" + min + ":" + sek)

        

       };

       setTimeout(t, 1000);
       

       t();

setTimeout does a thing only once, use setInterval for it to repeat it