LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get date/time function help understanding

so i am trying to incorporate a timer that displays how many hours/minutes/seconds the vi has been running for. I've searched around and realized that some people use the get date/time function convert it to dbl and my question is why? what does this do? I am having a hard time trying to implement this timer, maybe someone can outline it for me or clarify this?
0 Kudos
Message 1 of 6
(4,424 Views)
The why, if you think about it for a bit, should make alot of since.  You can do something like this the hard way or the easy way Smiley Happy.  The hard way is to do all of the math yourself.  IE take the current hour and subtract start, take current minutes and subtract start, etc.  Problems start to arise when you have a carry condition.  Lets say you start at 5:05:05 and its currently 6:02:086-5 = 1, 2-5 = -3, and 8-5 = 3.  The negative three is going to be wrong of course.  You have to borrow from the hours and give it more minutes and then do the subtraction.
 
Or... you can do it the easy way to start of with.  Get the current date time in seconds (or convert it).  Once you have it in seconds you subtract (no worries about carry conditions) and convert back to a time format.  In other words converting to seconds and back is easier than manually adjusting.  If you set your indicator for a time format what you want to do is actually simple.  See example...
 
 
0 Kudos
Message 2 of 6
(4,415 Views)
unfortunately, showing relative time does not work in the PDA properly for some odd reason. Smiley Sad
0 Kudos
Message 3 of 6
(4,400 Views)
unfortunately, relative time is not displayed  on the PDA Smiley Indifferent
0 Kudos
Message 4 of 6
(4,401 Views)
The get date/time function returns a string containing the time elapsed as UMT. Means that it adds /subtract hours depending on your local Window time settings. People convert it to seconds because it is sometimes required to do some maths on time, not just displaying or recording it as a string, or simply to add/subtract the required number of seconds to obtain the local time 🙂
Unfortunately, correction for negative time offset do not work immediately as the get date time string vi does not accept negative inputs ! Means that if you live east of Greenwitch, you are stuck (or you need to find a workaround).
 
You are right, the relative time function is not available as it on PDAs, but has been replaced by the equivalent PDA get date time in seconds, with the same icon (except the color) !
 
The attached vi shows different solutions and works on PDAs !
Chilly Charly    (aka CC)
0 Kudos
Message 5 of 6
(4,397 Views)
sweet.  I have a couple of questions with regard to your VI, how come you are not dividing the time by 300 since you are slowing down the vi by that interval. Also, is there a way to re zero the seconds once 60 seconds have elapsed? thank you for you help.
0 Kudos
Message 6 of 6
(4,362 Views)