Forum Academy Marketplace Showcase Pricing Features

How to convert total # of minutes into hh:mm?

Hi Bubblers,

How would you display a number field as hours:minutes? Example 135 minutes = 2:15


Hi there, @jasonturo… I’m sure there are a number of ways to do it, but here’s an example where a text element is displaying the hours and minutes (2:15) of an input field (called total minutes) where 135 has been entered.


Hope this helps.


1 Like
1 Like

I had hit upon this problem sometime back and had resolved to similar solution.

I’ll tell you the problems with this.

  1. Both hours and minutes will show in single character when they are in single digit. i.e. it would be like 3:5 while it would be nice to show 03:05. So to avoid this, we have to add extra formatting of identifying if it is less than 10 what to do etc.

  2. “Total minutes” is not always as easily available in one variable. If you are calculating the duration as a difference of some two entities, then it becomes one long expression and then you have to put it two times in this expression and the expression becomes very long and it seems like overprocessing for something small.

  3. If you have to do HH:MM:SS and not just HH:MM then complexity increases even more and you start wondering if this small thing will deteriorate performance of your app, and also whether you have got everything right.

  4. If you have to put this duration bit at multiple places in your application, then it is just so much cumbersome.

I did ultimately resort to this solution only as I couldn’t think of anything else. But it would be nice if there was either an in-built formatting of duration in HH:MM:SS just like how we can format date/time.

If not formatting, at least let us build functions which can return values when we pass something to them.

1 Like

Thanks for the suggestion, Mike. It’s almost there. As @Bubbleboy pointed out the result of 125 minutes is 2:5, not 02:05, which is the format I am hoping to display. This will not need days or seconds, thankfully! Any ideas? I suppose a few conditional if the values are less than 10, add a 0 in front?

Thanks again.

Yup, that’s what @mghatiya was saying, and I would likely go with the conditionals to get the desired format.

Oops, yes, what @mghatiya was saying. ;-).
@Bubbleboy , thank you for the plugin suggestion. I’ll check it out. Conditionals seemed to work in this case.

Appreciate the modulo expression, Mike. Have a great holiday season!

1 Like

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