LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does "To Timestamp" with 0 wired to the input return 01:00:00 01/01/1904 and not 00:00:00 01/01/1904?

I am trying to display the elapsed time during my test. When I subtract my reference time from current time I end up with an additional hour.
 
So if I plug in 173 seconds in I get 01:02:53.000 01/01/1904.
 
I don't know if this relevant but I have noticed that timestamp constants are coerced to this number.
 
I am in GMT Daylight Saving Time.
 
cheers
 
David
0 Kudos
Message 1 of 11
(4,188 Views)
Just to be sure - you are using Get Date\Time in Seconds before the test, use it again in each iteration and substract the old from the new, right?
 
This way, you should get a double, which you can format as relative time (by right clicking the indicator), and this way you should not get an hour's difference. Can you post your code?

___________________
Try to take over the world!
0 Kudos
Message 2 of 11
(4,172 Views)
There's a couple ways to display elasped time. Here are two of them. In both, the numeric indicator has the Format and Precision set for relative time.
0 Kudos
Message 3 of 11
(4,169 Views)
Yep, I am being careful on how to count the seconds.
 
I have attached a simple vi in LV7.1 that demonstrates the issue. You supply a number in seconds, convert to timestamp then format the timestamp into a hours:minutes:seconds style for a string indicator.
0 Kudos
Message 4 of 11
(4,148 Views)

Timezone. 

When I run your VI, I get 0 seconds being 19:00:00 which is 5 hours behind 0 which is right as I am 5 hours behind GMT.  Zero at GMT is 19:00:00 local time (CST).  You are obviously one hour ahead (central europe). 

It should work out OK if you have the same offset on both sides of the equation.  If you start at noon local time and stop at midnight local time, it should be 12 hours reguardless of where the local time is.

Hope that this helps,

Bob Young

 

0 Kudos
Message 5 of 11
(4,143 Views)
I think others have mentioned here other ways of handling elapsed time.  As to your original question, I think it's a time zone issue.  Note that the help entry for Get Date/Time In Seconds says, "...number of seconds that have elapsed since 12:00 a.m., January 1, 1904, Universal time." On my system, US Central Time (GST-6:00) when I wire up 0 seconds to the Seconds to Date/Time function, it actually returns 19:00.00 12/05/1903, which I think would actually be a negative time. I changed the computer's clock to be in a different time zone, and that result changed to 18:00.00 12/05/1903. So I think when the timestamp datatype is converted to a double, there is a time zone conversion as well.

Since you're only interested in elapsed time, and not an absolute time, why not just take a timestamp when your VI starts and used that as your zero time?  Or if you have an array of timestamps in your VI, use the 0th index and subtract that from the rest of the array.
0 Kudos
Message 6 of 11
(4,140 Views)
When my test sequence starts I use Get Date/Time in Seconds then convert that time stamp to a double and save that in a shift register.
To get the elasped time, I then use Get Date/Time in seconds convert the time stamp to a double.
I subtract the two numbers to get the number of seconds.
The number of seconds is the converted back to a timestamp.
The timestamp is then fed into Format Date/Time String to get the HH:MM:SS then send that to my indicator that reminds the test operaor how much of his life is dwindling away.
 
I have just finished typing all this and now I am thinking that I should have just done another demo vi. %&@!
 
The thing is that I have tried to tweak the "one hour ahead" thing out and its not letting me do it. Yet.... I like a challenge.
0 Kudos
Message 7 of 11
(4,138 Views)
You're making it much too complicated. No need to convert anything to a double or anything back to a time stamp. Look at the example I posted. Directly subtract the two timestamps and wire the output to a double. Use format and precision to display the double as relative time.
0 Kudos
Message 8 of 11
(4,128 Views)
The workarounds suggested will work nicely. I found this by accident and didn't quite get it. Still doesn't make sense why there is an effect caused by the time zone. Live and learn.
 
Thanks to all.
 
David
0 Kudos
Message 9 of 11
(4,115 Views)

Quit converting everything. Subtract your start time (as a timestamp) from your end time (as a timestamp), the result will be a double. Wire that to a numeric indiactor. Set Format & Precision to be Relative time. Voila'.

0 Kudos
Message 10 of 11
(4,111 Views)