Decimal Time to Minutes and Seconds


I am making a sports app and I am trying to display the correct time details for the current matchup.

Right now the API call brings in a UNIX timestamp and I have converted it to a number but it has decimals.

Any clue how to convert this decimal to MM:SS?

Thanks in advance!

Mobile View

Hi @reidbrown23,

If you’re using the API Connector, you should be able to indicate that it’s a date when you initialize the call. Bubble will automatically turn it into a native Bubble date.

Hi @sudsy !

My apologies… It is actually is displayed as time played in seconds. Any suggestions for how to format it?


Also, on that. Let me offer some additional context.

In a NHL game there are (3) 20 minute periods in regular time. So the thresholds for period is:

Period 1: 0> X<1200
Period 2: 1200> X<2400
Period 3: 2400> X<3600

Essentially after 1200 seconds the mm:ss needs to reset to reflect a new 20 minutes.

Hope this helps!

Oh, ok. That’s not a UNIX timestamp. That’s just a duration. It simply represents a certain amount of elapsed time.

Since you know it represents elapsed time in seconds, just divide by 60 to get minutes and use modulo to get the remainder in seconds…

elapsed_secs/60:floor : elapsed_secs<-modulo->60

That will give 59:55 for the value you have highlighted.