Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clock.ontick question

ANSWERED

New programmer here... I have created a clock face that has a primary time that is always displayed.  Below that is either the UTC time or the date.  What is displayed changes with .onclick.  My problem is that I can only update one item based on clock.ontick.  So, I can either update the primary time, the UTC time or the date.  How do I update both clocks at the same time?  My current work around is to force an update when I click on the element to show it again.  My next feet of daring will be to add in a third option of displaying my current steps.  I shouldn't have to cycle through for these items to update.  Any help would be appreciated.

 

Jeff

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You should be able to move your logic inside a single update procedure, something like:

 

 

function updateClock() {
let today = new Date(); // Update primary time
// Update UTC time
// Update step count } clock.ontick = () => updateClock();

 

 

 

 

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

You should be able to move your logic inside a single update procedure, something like:

 

 

function updateClock() {
let today = new Date(); // Update primary time
// Update UTC time
// Update step count } clock.ontick = () => updateClock();

 

 

 

 

Best Answer
0 Votes

Thank you.  I knew there had to be an easy solution!

 

 

Best Answer
0 Votes