# Getting Hours/Minutes/Seconds separately

I am using the timer component and saving the total time it was used into to my collection. Now I want to sum the time saved for the day. I am saving the milliseconds as well as the text hours:minutes:seconds from the timer component. So if I saved 1:30 and 5:35 when I sum the two I should get 7 minutes and 5 seconds. Currently I can only sum the total milliseconds and I can convert it but then I cannot have x minutes and x seconds. It turns out to be 7.05. How do I split that up to read 7 minutes and 5 seconds? or x hours, x minutes , x seconds? Or is that even possible right now?

Following! I would like to know the answer too

1 Like

Hi @djack,

If you store 1:30 and 5:35 as a text records, then it would be difficult to split them into minutes&seconds without using extra services. I think Integromat string functions might help.

I would suggest storing the total time in milliseconds in a collection record, and then convert them to hours-minutes-seconds to display them. Iâ€™ve created a small POC how to convert milliseconds, pretty simple, here are the screenshots:

The app screen itself

Iâ€™ve created 4 properties to store Hours, Minutes, and Seconds, and the fourth one is to store initial value in seconds (see the left side of the screenshot). All property names start with EX20. First step is â€śUpdate Userâ€ť action where I store the seconds value.

And the logic itself: here I calculate Hours, Minutes & Seconds.
With hours it is simple: to get number of hours, I take the integer part of Total Seconds divided by 3600.
To get the remaining minutes, I need to put away the hours from the initial Total seconds, and then divide the remaining by 60, and take the integer part of it.
And the same logic applies to seconds - I put away the number of minutes.

This should work correctly, as per my checks.

Best,
Victor.

3 Likes

This is exactly what what I was trying to do. I am saving to milliseconds and was converting to seconds but could not figure out how to get rid of the remaining digits after the decimal. Thanks so much for your help. I wish I would have asked sooner.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.