Timer Display launched and displayed on page open

Hello
My very first post!
I have managed to set up the time on the Global Canvas as per below;


I have also created a page variable for the timer starting (i.e. when that page is ‘launched’) as per below;

Finally, on that page, I have the created a page variable for the timer being stopped (attributed to a ‘Stop’ button…if this is ‘empty’ the timer continues to run) and also created the below formula to display the timer (in a paragraph component);

IF(IS_EMPTY(pageVars.TimerEnded), DATETIME_DIFFERENCE(appVars.TimeNow, pageVars.TimerStarted,“hh:mm:ss.000”),DATETIME_DIFFERENCE(pageVars.TimerEnded, pageVars.TimerStarted,“hh:mm:ss.000”))

My questions;

  1. The timer works but displays as a number such as 1682 which is one second and 682 miliseconds. How could I amend it to something more readable? Ideally something like 00:01:682
  2. I would like, in addition to the timer, a display that is driven by the timer. Say between 0-2 minutes, it says ‘0’, after 2 minutes until 5 it says ‘1’. Any suggestions as to how to do that?
  3. Can I confirm Event = PAGE MOUNTED is simply the page opening and nothing more? The reason I ask is that on the same page as above, I have an audio track that plays on that event. While I am working on my laptop, my phone with the appgyver app occasionally plays the track totally unprompted by me!?

Thanks

Hi!

  1. You would have to do this conversion yourself, but it’s just math. I use this for a conversion from seconds to minutes:seconds format, adjust it to your needs: FLOOR(privateVars.slider_value / 60) + ":" + LEFT_PAD(STRING(FLOOR(privateVars.slider_value % 60)), 2, "0")
  2. This is more of the same math as above, but then just adding an IF around it with matching to the values, so IF(YOUR_MINUTES_CALCULATION_FORMULA<2,0,1)
  3. Page mounting happens actually before the page is opened. It happens every time before the page is opened (unless it wasn’t closed). If you have the page in a navigation menu, it is mounted every time the app opens, basically. Use page focused if you only want something to happen after page is in view.

Thanks for your help Mevi.

  1. I had progressed to using DATETIME_COMPONENT for each part of the timer and linking them with “:” but it looked slightly unprofessional as I couldn’t get LEFT_PAD to work due to data type issue (16:6:789 looks odd compared to the desired 16:06:789). But your formula above that includes STRING solved that riddle for me. I tinkered with your conversion example but ended up going with what had evolved but with STRING added in:
    LEFT_PAD(STRING(GET_DATETIME_COMPONENT(DATETIME(DATETIME_DIFFERENCE(appVars.TimeNow,pageVars.TimerStart)),“minute”)),2,“0”) + " : " + LEFT_PAD(STRING(GET_DATETIME_COMPONENT(DATETIME(DATETIME_DIFFERENCE(appVars.TimeNow,pageVars.TimerStart)),“second”)),2,“0”) + " : " + LEFT_PAD(STRING(GET_DATETIME_COMPONENT(DATETIME(DATETIME_DIFFERENCE(appVars.TimeNow,pageVars.TimerStart)),“millisecond”)),3,“0”)
  2. I had come to that conclusion as well, though the heavy-duty nature of the nested IF functions I need means some of my formulas are too big and I crash Composer. Going to post a separate topic on that.
  3. Thanks for the clarification. As above, I am at the point where the answers to really simple questions open up so much knowledge to me.
    Thanks again
1 Like

Hi!
I ended up needing your same timer and I found your topic. I was wondering if you made it work and if you could help me with the formua to bind the paragraph (timer display) with.
Thankyou in advance!