LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm using the FORMAT DATE/TIME STRING FUNCTION and having a slight problem...

I want to keep track of how long my VI has run so the operator has a clue of how long before the VI stops.
I'm using the FormatDate/TimeStringFunction.VI and
I have the TIME FORMAT STRING terminal filled in with the following %H:%M:%S but each time I start the VI the indicator shows 19:00:00 before it starts to count. How do I get rid of the 19 is this some type of universal setting? Do I have to set a relative setting somewhere?
I want to see 00:00:00 when I start my VI how's this done.
0 Kudos
Message 1 of 9
(6,690 Views)
The Format Date/Time String function returns the date time string since 12:00 AM, Friday, January 4, 1901 Universal Time (UT: I think that used to be known as GMT). The time is displayed for your time zone. 0 seconds = 12:00 AM UT = 19:00 (or 7 PM) Eastern Standard Time. If you change time zone (or go to Daylight Savings Time), time 0 will change for you. Format Date/Time String isn't really intended to be used as a timer.
You may want to use Get Date/Time in Seconds. Call it when you want to start your timer, then call it again when you want to display the time. Subtract the two values and parse it into H:M:S yourself.
0 Kudos
Message 2 of 9
(6,689 Views)
Here's a LabView 6.1 example of a timer as I described above.
0 Kudos
Message 3 of 9
(6,689 Views)
> You may want to use Get Date/Time in Seconds. Call it when you want
> to start your timer, then call it again when you want to display the
> time. Subtract the two values and parse it into H:M:S yourself.

Once you have a delta time, you can display it using the Relative Time
format of a numeric indicator. It displays the time as H:M:S.sss where
s is a fractional second digit and H goes above 24 with no day, week, or
month elements available.

Greg McKaskle
0 Kudos
Message 4 of 9
(6,689 Views)
What if you use the Seconds to Date/Time.VI or should I ask what seconds does this VI use? Seconds it generates itself once called? or seconds provide by the created VI. For example I have a While Loop thats set to cycle every second (1000mS). How can I used the iteration (which will imcrement every second) as the seconds that will be used by the Seconds to Date/Time.VI and convert this count into time using the Seconds to Date/Time.VI? If this is possible.

By the way your example is slick thank you.
0 Kudos
Message 5 of 9
(6,689 Views)
Using the Relative Time (seconds) option under the Decimal format, I couldn't find a way to display hours and minutes if they were zero. So the format isn't always H:MM:SS. That may (or may not) cause some confusion with the operator.
E.g.
T = time in seconds, RT = time as displayed in Relative Time, H:MM:SS displays hours and minutes, even if 0.
T RT H:MM:SS
0 0 0:00:00
59 59 0:00:59
61 1:01 0:01:01
3661 1:01:01 1:01:01

So I used a string.
0 Kudos
Message 6 of 9
(6,689 Views)
Seconds to Date/Time has a seconds input. If seconds = 0, the function reads the current time. Get Date/Time String and Format Date/Time String also have seconds inputs and behave the same way.
The LabView Time & Dialog functions that display time (including Seconds to Date/Time) display time converted to your time zone. So you're back to your original problem of time 0 = 19:00:00. That's why I suggested using a string.
How accurate do you want your timer to be? Reading the time in seconds using Get Date/Time in Seconds (which actually returns seconds.milliseconds) will be more accurate than using Wait (ms) or Wait Until Next ms Multiple in your loop. The Wait functions guaruntee a minimum delay in your loop, but the actual interation
time may vary, depending on wait else your loop does and what else Windows is doing at the time.
If you're not that concerned with timer accuracy, you can use the iteration count as a timer. But I would still convert it to a string with H:MM:SS as I did in my earlier example.
Look at Greg's comment and my reponse to it for another approach.
0 Kudos
Message 7 of 9
(6,689 Views)
Oops: I meant if the seconds input is unwired (not if seconds = 0) the function reads the current time.
0 Kudos
Message 8 of 9
(6,689 Views)
Is there a way to modify the Timer.vi posted to make it so it have a higher second precision say like 5-9 digits?  Thanks.
0 Kudos
Message 9 of 9
(6,280 Views)