Creating a timer

Hello fellow bubblers,

I’m currently struggling with creating a timer that counts up when the “Time Start” button is pressed that will activate in the “Time Elapsed” input box.

When “Time Start” is pressed, the input box will populate with the exact time the button is pressed. Additionally, I want the elapsed time to also populate with a timer that begins counting. I know I most likely have to use the do every 1 second workflow method, but I cannon manage to figure out the right logic for it.

Here is what I have so far:

Any help would be appreciated!

1 Like

Rather that use an input, you could try having the 1 second workflow set a state to “current time” each second.

Then use that state to display something in a text element.

This has the elements split out, but the idea is similar.

https://buildingonbubble.com/block/countdown-timer-1466528802569x695336233767534600

1 Like

Nigel,

Thanks for the reply. Unfortunately, I couldn’t preview the application as the results say expire and I cannot seem to add anything. However, I did try to look at the logic and I’m more so looking for something that will count up from 0, rather than countdown to 0.

Sorry if this app covers that, but I couldn’t follow it very well. I noticed that you created a database as well. Should I create one? In most of the forums I’ve read, it doesn’t seem like I should have to create a database when I want to do something ever 1 second.

Sorry for not understanding all of this, but I appreciate your help!

Sorry, my fault, had pointed you to the wrong thing…

https://buildingonbubble.com/block/formatted-countdown-1471178176900x842421891177381900

Nigel,

I’ve gotten it to partially work thanks to your link! Thanks! The only thing I really need to figure out is that I have to actually click my buttons for the timer to actually update. The do every one second option isn’t automatically updating it for me. Am I missing something?

Thanks!

You will need to use the “Elapsed” state in a text element, by updating it every second it should change the display.

I’m having a hard time understand which element to set to a text state. I tried to mimic yours, but I think I’m getting off track at this point. Would you mind taking a look at what I have done and seeing exactly where I went wrong?

Thank you

https://bubble.io/page?name=index&id=cdiff-tracker&tab=tabs-1

Hi there,

Have updated, you needed to take the “ticking” elapsed time and subtract the start time.

I have also …

a) Added a condition that when the timer hasn’t started yet it shows “ready to start”.

b) when the timer has stopped, it shows stoptime - start time (although I haven’t formatted this yet).

Hope that helps.

1 Like

i have a repeating group that shows posts that were made, along with dynamic text that indicates the current time-current cell post creation date:formated as minutes, and i want this to update every minute, so for example if the text says 15 minutes ago, i want it to change when it becomes 16 minutes ago, would this work for me or do you have another solution for this?

Nigel,

This is brilliant! Thank you for adding the conditional formatting for the timer as well. It really helped me to understand what was going on. I’m still having trouble understanding why exactly I could not get the timer to update itself every second. Is it because you had a when page is loaded function and I did not?

The only other question I have is this: Is there a way to just get it to end in minutes? For example have it say 70 minutes instead of 1 hour 10 minutes?

Thanks so much!

1 Like

Any help on my last question? Thanks bubblers!

Sorry, missed your reply.

Yes, that is much easier. Just subtract the two times and format as seconds, divide by 60, subtract 0.5 then round to zero. I think that should do it.

The fiddly bit is because Bubble rounds up on 0.5 so 30 seconds becomes 1 minute if you do it in minutes (if that makes sense!).

Have added a new field to show it working.

1 Like

If you can pick the “floor” function it should do this, i.e. it drops off the fractional component.

Edit oops you want to “round down” rather than floor, pls disregard my reply.

Edit again - I agree with my first answer… shouldn’t be on here when too tired :stuck_out_tongue:

2 Likes

These new fangled things. Didn’t have floors in my day, it was all cornfields etc :slight_smile:

2 Likes

You guys crack me up. I love coming here and seeing all this interaction. I’m finally getting the chance to give back a little as well and it’s great. Thank you all so much for your help and feedback. Nigel thank you a ton for all the help you’ve given me. I was easily able to setup and follow along with everything.

Case closed!

1 Like

Hello all,

So I’ve created the time and have done some testing however, I’ve realized that after 4 minutes, the timer will only count seconds. For example, when the time hits 4 mins. 59 secs. it should change to 5 mins. 00 secs. but it is changing to 4 mins. 60 secs. 61 secs and so on. Is my logic right for the dynamic data?

Thanks.

Its great that you’ve discovered a flaw in the formula : )

For testing these I recommend building a little testbed to play with the inputs, something like two date/time pickers, a seconds offset input, and then the calculations, like:

For the seconds-only component, you want to use “clock arithmetic” so that counting from 59 takes you to zero, this is called “modulo”, and pick a base of 60.

Here I have an additional input to test seconds, whereas yours will just have stop and start.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.