Forum Academy Marketplace Showcase Pricing Features

Display total time in hours and minutes

Hi all! I’m stuck with something. I’ve time duration fields as number data. They store time in minutes.

I’m trying to do some calculation on it, and to display them as 10h23min or 27h38min

The trick to use an arbitrary date/time + minutes in not good there because sometime the total time is > 24hours.

The only thing I found is using hidden input, one for total time, the second for hours (total time / 60 floor rounded to 0) and the third for minutes (total hours - total time in min * -1 ) and displaying text as “INP hours” h “INP minutes” min

This is nice but gets very tricky when there’s negative time like -0h30 is displaying 0h-30 or if min are < 10 example : 6 min displays as 0h6min instead of 0h06min…

Is there a plugin or another way to make it simplier ?

thanks !!!

Hi @Sarah_Esteve !

Why don’t you treat theese “erros” before display them?

1) IF minutes < 0
In this case, you just need to multiply re result by -1 to fix it.
So 0h-30min will became 0h30m
And display a “minus” sign in front of your text:
So 0h30min will became -0h30m

Do the same if the hour is < 0.

1) IF minutes < 10
In this case, just put an extra “0” before your minute value.
So 0h9min will became 0h09min.

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