# Convert seconds to hh:mm

Hi All

I’ve very new to bubble, I making an app to track fitness stats, the data is being pulled into bubble via an API and and time format is in seconds. How on earth do I convert this is hh:mm for use in charts and graphs? In Airtable, I could simply import that data in seconds and set the field to hh:mm and it’s done. Is there a way to do this in Bubble?

Unfortunately, when the data is pulled from Airtable, is it converted back to its raw format, and I don’t see any time functions in Bubble!

Thanks!

Hey wayne welcome to Bubble !

You can use mathematics to do the conversions, here are the formulas :

HH = TimeInSeconds / 60 / 60 modulo 24 - 0.5 :rounded to 0
MM = TimeInSeconds / 60 modulo 60 - 0.5 :rounded to 0

Got it from this youtube video from coaching no code apps where they show how to build a countdown clock:
click here

Thanks, just watched the video but unfortunately is doesn’t help. I’m not working with a date, I’m working with a duration. I can do the math, what I can’t do is convert a field with a static number, representing seconds, into an hh:mm format. This should be so simple, like in integromat I’d do this:

Can I set a variable in Bubble?

Hello @wayne.simpson84 welcome to the community!

Complementing @benoit.devilliers great advice here.

Dates are at their core … numbers (expressed in milliseconds and formatted in various human-readable ways such as mm:dd:hh etc etc)

Bubble is at its core a visual programming language so this is why most functions need to be programmed in a granular way unlike Airtable or Integromat where they provide pre-programmed functions.

Thanks both, I’m still a bit confused as to where/how to do this, I don’t suppose anyone could show me some screenshot please? I’m still very new to Bubble but currently this has put my Project on hold

Hey wayne, I’m assuming you have a variable that hold the second values, what you can do is to use a text element do : insert dynamic data, then you choose the variable that hold your seconds, then you convert it to hours using TimeInSeconds / 60 / 60 modulo 24 - 0.5 :rounded to 0

After that you can repeat the operation with the minutes but with this formula this time : TimeInSeconds / 60 modulo 60 - 0.5 :rounded to 0

If it doesn’t help, can you upload a picture of where you want to display these values ?

Or maybe you don’t want to display it but to store the values in your bubble database ?

Thanks Benoit, the value is stored in Airtable which is integrated by the API connection.

I’m on the fence as to if I should use the API or add the value to the Bubble database, one of the too.

I don’t have a variable, as I don’t know where to set one in bubble! I’ve clearly got a lot to clear moving from Airtable and Integromat!

From my point of view Bubble is made so that it can work alone without external database, that’s why some other tools like webflow or softr are plugged to airtable and use it as database.
It seems that some people are using Bubble + Airtable but from my understanding it means that you have to maintain the database twice (once in Bubble and once in Airtable) but i’m not an expert with these setup so…

Maybe we can come back to the moment when the data is pulled from Airtable ?

When it comes to variables in Bubble you should have a look in the data tab , it would allow you to start replicating your Airtable database