# LabVIEW

cancel
Showing results for
Did you mean:

## Convert Seconds to Hours:Minutes:Seconds

If I have an integer holding the number of seconds, how can I convert it into a string/relavant format in the form Hours:Minutes:Seconds?

For example, 123 seconds should be 00:02:03.

If it is possible to do the above, then how can I seperate it into 00 Hours indicator, 02 Minutes indicator and 03 Seconds indicator?

Message 1 of 22
(32,880 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

You can do that manually. For one of my project I have made the calculation to convert the seconds to time. This will convert the seconds into to only Hours Minutes and seconds and not into the actual time format.

Good luck

-----

The best solution is the one you find it by yourself
Message 2 of 22
(32,876 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

Here are some alternative solutions, there are many more. (VI is LabVIEW 8.2)

Message 3 of 22
(32,871 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

Optimization ends here.

-----

The best solution is the one you find it by yourself
Message 4 of 22
(32,857 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

/Y

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 5 of 22
(32,839 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

@Yamaeda wrote:

/Y

But this will convert the hours to days once it exceeds 24. Also you don't have to convert you can wire the seconds directly.

-----

The best solution is the one you find it by yourself
Message 6 of 22
(32,830 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

Here's another way to do it.  Format you DBL indicator to display absolute or relative time.

Message 7 of 22
(32,819 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

And Wayne's can be simpler if you dont mind the coercion dot. 😄

It does however have a 1 hour add, causing 123 to turn into 01:01:59

/Y

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 8 of 22
(32,804 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

@Yamaeda wrote:

And Wayne's can be simpler if you dont mind the coercion dot. 😄

It does however have a 1 hour add, causing 123 to turn into 01:01:59

/Y

Keep it as relative time and you don't.  I'm thinking the Absolute Time will get adjusted due to time zones.  Mine is showing 19:02:03 when set to absolute time (Eastern Time = -5 from GMT).

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 22
(32,795 Views)

## Re: Convert Seconds to Hours:Minutes:Seconds

Altenbach already did it the absolute simplest way to do it.  Format an Integer indicator to display time.  I added the DBL version just to remind people that you can do the same with a DBL as well. You can also get fractions of a second as well if dealing with a true timestamp.

Message 10 of 22
(32,791 Views)