From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

display time in specific format

Hello, everyone. I have a question on formatting time in numerical values (double 64-bit) to specific format.

 

An example: 1013.49700, which is converted to excat format of "hhmmss.sss". In this case, hh=00, mm=10, ss.sss=13.497

So, I want 001013.497. Are there any way(s) to do this? Thanks a lot.

 

Regards,

yukfai88

0 Kudos
Message 1 of 11
(3,589 Views)

I believe you want the format string %<%H%M%S%3u>T

 

You can use the Advanced editing mode under the Display Format tab of a datetime stamp to see the full setof date time options...


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 2 of 11
(3,579 Views)

Hi Philip,

 

the format is what I want, by having the format of hhmmss.sss, but I don't know why the numeric value of "84843.896" will be converted "073403.896". Are there way(s) to restore the original time? Thank you.

 

Regards,

yukfai88

0 Kudos
Message 3 of 11
(3,546 Views)

Where did 84843.896 come from?

 

Why don't you post your VI as it stands right now.

 

And what do you mean by "restore the original time"?

Message Edited by Ravens Fan on 03-23-2010 12:04 AM
0 Kudos
Message 4 of 11
(3,538 Views)

Hi yukfai,

 

your numbers aren't real time values. LabVIEW counts time in seconds, so 1013.4 is a time in seconds or 16m53s400ms.

To convert your numbers you have to split them into separate values for h,m, and s by using some modulo operations (hours = x \ 10000, minutes = (x - 10000*hours)\100 and so on...)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 11
(3,525 Views)

GerdW wrote:

Hi yukfai,

 

your numbers aren't real time values. LabVIEW counts time in seconds, so 1013.4 is a time in seconds or 16m53s400ms.

To convert your numbers you have to split them into separate values for h,m, and s by using some modulo operations (hours = x \ 10000, minutes = (x - 10000*hours)\100 and so on...)!


 

Or use the formating string as shown by Phillip Brooks. But I would change it to %<%H%M%S%3u>t since the OP seems to be interested into relative time formatting rather than absolute time formatting.

 

The difference is that relative timeformatting is the seconds since 00:00:00 while absolute time formatting is the seconds since January , 1904 UTC, 00:00:00. This means that when you use absolute time formatting, the current timezone offset will be calculated in before the time is displayed.

Message Edited by rolfk on 03-23-2010 09:25 AM
Rolf Kalbermatter
My Blog
Message 6 of 11
(3,514 Views)

Hi rolfk,

 

yukfai wants this:

"1013.49700, which is converted to excat format of "hhmmss.sss". In this case, hh=00, mm=10, ss.sss=13.497 So, I want 001013.497"

 

As said before: 1013.497 will result in 0h 16m 53s 497ms when using internal timestamp formatting. But the user wants to display 0h 10m 13s 497ms! So he has to "split" the number using modulo operations.

 

@yukfai:

Could you please clarify what is the expected result for "84843.896"? Is it 8h 48m 43s 896ms or 23h 34m 3s 896ms?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 11
(3,493 Views)

Thanks for help, GerdW and rolfk.

 

My desired output from numerical value of  84843.896 is in 08h 48m 43s 896ms. But I can't simply convert it to the form of having 6 digits before decimal point and three digits after the decimal point. Are there any format code to achieve this? Thanks a lot.

 

Regards,

yukfai88

0 Kudos
Message 8 of 11
(3,480 Views)

Hi yukfai,

 

see message 5...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(3,477 Views)
If it's just the formatting of the digital display you need, take a look at the Display Format:
Download All
0 Kudos
Message 10 of 11
(3,462 Views)