How do I connect a timer across screens and show the time?

Hi! I’m trying to make a step tracker where when you press the start button on the 2nd screen, a timer fires but you only see the time elapsed in the 3rd screen (stats)


But it’s showing up like this and not tracking the time properly…help pls…

It isn’t necessary to add the update time since you already have the updateElapsedTime function in your code. As long as your timers are starting at 00:00:00, and your timer is counting up by every second, it should be fine. Milliseconds can also count too.

I can provide an example below for you:

Set your update time function:

function "update time"
  forever:
    wait 1 seconds
    change app variable formatted_seconds by 1
  forever:
    wait 60 seconds
    change app variable formatted_minutes by 1
  forever:
    wait 3600 seconds
    change app variable formatted_hours by 1

Formatted Time function:

function timer:
  if app variable TimerRunning = true:
    format time
    set Time_text text to:
      join:
        formatted_hours, ":", formatted_minutes, ":", formatted_seconds
    else:
      set formatted_hours to 0
      set formatted_minutes to 0
      set formatted_seconds to 0

Another error you’re probably encoutering is the zeroes. You’re combining a string and a number, which is not exactly ideal. Instead use number variables, and that might make your process a little better :melting_face:

If you could also tell me where you are testing this app on, that may be more useful to my understanding.