LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to format a time stamp into string hhmmss?

I am going to use the time stamp as filename. I want the format should be HHMMSS. But when I convert the time to string, it always skip the zero. So, 07:01:01 becomes 711. (I wish it could be 070101). Any simple way to do it?
Thanks!
0 Kudos
Message 1 of 6
(4,195 Views)

Hello,

You should be able to accomplish this pretty easily with the Format Date/Time String function, and "%H%M%S" (without the quotes) specified as your format string.

Good luck,
-D

0 Kudos
Message 2 of 6
(4,186 Views)
I don't know how you were doing it, but this is how I would go about it.  (Current time 2:25:45 pm)


You may have been using %#H%#M%#S, which removes the prepending 0's.

Message Edited by jasonhill on 03-17-200602:31 PM

0 Kudos
Message 3 of 6
(4,188 Views)
Thank you, guys. The reply comes so fast! I love this forum.
My problem is that I have only "seconds". I can convert it to date/time cluster. I pick only Hour, Min, and Seconds from that cluster  and build a string. Then I have the above mentioned question.
I know I can rebuild the time stamp and then format to the string. I also search and find the vi by tst. It looks like a complicated process. (Maybe not?)
I am just curious whether there is any easy way to work directly on the string. For example, I have 7, 11 and 1. How to get it as 071101? Any "string format" vi can do it just like that for time stamp?
Thanks!
0 Kudos
Message 4 of 6
(4,176 Views)
Rather than muck around with the timestamp functions, you can just convert straight to a string.  Note: I used the DBL conversion just so I could have an arbitrary # of seconds.


Message Edited by jasonhill on 03-17-200603:30 PM

0 Kudos
Message 5 of 6
(4,167 Views)

Great! That solves my problem.

Thanks!

0 Kudos
Message 6 of 6
(4,155 Views)