Clock update automatically in the Dashboard

I try to display the actual time in the Dashboard but I don't know how can i do.
It works with a button but i don't know how can I do automatically.
Thanks in advance for our help.
My code:


function Init(form)
  var now=new Date();
  form.Hour.value    = now.getHours();
  form.Minute.value  = now.getMinutes();
  if (form.Minute.value<10) form.Minute.value = "0"+form.Minute.value;
  form.Second.value  = now.getSeconds();
  if (form.Second.value<10) form.Second.value = "0"+form.Second.value;
  form.Day.value     = now.getDate();
  form.Month.value   = now.getMonth()+1;
  if (form.Month.value<10) form.Month.value = "0"+form.Month.value;
  form.Year.value    = now.getYear()+1900;



<FORM NAME="Clock">

<TR><TD>d.M.Y</TD><TD> <INPUT TYPE="text"  NAME="Day" SIZE=2>.
    <INPUT TYPE ="text" NAME="Month" SIZE=2>.<INPUT TYPE="text" NAME="Year" SIZE=4></TD></TR>
    <INPUT TYPE ="text"  NAME="Hour" SIZE=2>:<INPUT TYPE="text" NAME="Minute" SIZE=2>:<INPUT 
           TYPE="text" NAME="Second" SIZE=2></TD></TR>
<TR><TD colspan=2 align=center>

<INPUT TYPE="button" VALUE="clock-update" ONCLICK="Init(this.form)">


The approach I would take would be to use an inject node triggering once a second (or whatever) and generating a timestamp. Then format that in the required way using node-red-contrib-moment (or do it in a function node if you prefer) then send this to appropriate display objects in the dashboard to show it.


Not sure if this is what your looking for? It puts a real-time clock in the dashboard title bar.

@Colin, @Randy: Thank you for our inputs.

I would like to use my code like this because the clock is only a part of my template and so I would not like to use the inject node. But it is a solution.
I just found this post but I would not like to put it on the title bar but in the site like my examplecode. I' m not an expert and so I have problems to change the code.

has nobody an idea? :worried:

You've been offered two suggestions so far... but apparently neither meet the brief you want. You may need to either be more patient and hope someone happens to have an exact fit - or roll up your sleeves and start playing around with the code while you wait.

Hello @dceejay,
thank you for your answer.
Yes, thats true, I'm verry happy for our help and suggestions.
I'm a beginner and so I don't understand everything at the begin, sorry.
I thought it is easier to run the posted example in node red...
Now I try to roll up my sleeves and start playing around with the code while I wait.
Thank you for your understanding and patience.
Thanks again for our work and helpfulness.