LAVA Forums Buy cool LAVA gear Forums RSS Feed

Welcome Guest ( Log In | Register )

> Related links

Check out our General Code Repository Files. Also, before posting here, check to see if your post doesn't fit into another subforum by category.


Tags
(This content has not been tagged yet)
 
Reply to this topic Start new topic
> Converting Windows Time From Labview Time, How to convert LV time to C time
JackHamilton
post Jan 6 2004, 04:05 PM
Post #1


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


The LabVIEW timestamp is different from 'C' timestamp. The origin dates are different. LabVIEW is Jan 1, 1904. 'C' time is Jan 1,1970.

If your passing timestamped data between LabVIEW and C you will need to adjust the LabVIEW timestamp by 66 years in seconds.

However, different values for the offset have been suggested. The correct offset in seconds is: 208138000 - this is simply 31536000 (a years worth of seconds) x 66(years)=2081380000.

To check, if you recovert the seconds back into LabVIEW time the clock should be off by 66 years but the hours and time of day should be the same. Some constants proposed have a 1 hour offset. (Although I am scratching my head about leap years which logically should subract a day for every 4 years. (16.5 days for 66 years) but the simple calculated offset is still correct)

Regards

Jack Hamilton


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Ad
post Jan 6 2004, 04:05 PM
Post #















Tags
(This content has not been tagged yet)
Go to the top of the page
Quote Post
Michael_Aivaliot...
post Jan 6 2004, 05:45 PM
Post #2


Confucius say: Crowded elevator always smell different to midget
Group Icon
*****

Admin
Posts: 2402
Joined: 13-October 02
From: Planet Earth
Member No.: 2
Using LabVIEW Since:1994
LV:8.5 ,8.2.1 ,7.1.1
Greece Canada United States My Blog My Gallery


QUOTE (JackHamilton @ Jan 6 2004, 11:05 AM)
To check, if you recovert the seconds back into LabVIEW time the clock should be off by 66 years but the hours and time of day should be the same. Some constants proposed have a 1 hour offset. (Although I am scratching my head about leap years which logically should subract a day for every 4 years. (16.5 days for 66 years) but the simple calculated offset is still correct)

Actually, Jack you are right, there is a leap year issue. I'm not sure why it is working for you because it is NOT working for me. I think you should NOT just subtract the 66 years in seconds. You should be subtracting the number of seconds until jan 1 1970 from 1904.
Attached image(s)
Attached Image
 

--------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
JackHamilton
post Jan 7 2004, 04:35 AM
Post #3


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


Michael,

This is why I was asking for a windows function call in LabVIEW that would call the same time reference as a C on the Windows OS.

Hmmm.... wacko.gif


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
JackHamilton
post Jan 8 2004, 04:04 PM
Post #4


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


clock.gif
Here is a VI that outputs all three time references Jan 1, 1904, 1970 & 1980. Keep in mind that the LabVIEW "Seconds to Date & Time" will not resolve the date correctly for the 1970 and 1980 reference.

This VI does not simply subtract 66 years, but calls the time convert function in LabVIEW which (*should*) perform all the proper timezone and leap year adjustments.

You should see the today's date in the 1904 reference, the same time but 1970 in the 1970 box and etc for the 1980 box.

Good Luck.
Attached File(s)
Attached File  Time_Since_1904_1970_1980_N1.vi ( 59.93K ) Number of downloads: 810
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
cengique
post Aug 10 2005, 08:07 PM
Post #5


One hit wonder!


Member
Posts: 1
Joined: 10-August 05
Member No.: 2734
LV:7.1.1
Nothing Selected


Sorry but your VI outputs the wrong times. You really need to calculate the number of seconds elapsed between the 1904 date and 1970 date. Simply subtracting the year doesn't solve the problem.

Anyway, in my case I needed that number of seconds to subtract to adjust the 1904-based mac date to 1970-based unix date. The value above in the first message of the thread gave me a 16-day offsetted date. So I calculated my own number: 2082816000. This is the number of seconds elapsed between 1/1/1904 and 12pm 12/31/1969. I used the attached VI Attached File  Time_conversion.vi ( 18.83K ) Number of downloads: 857
to ask LabVIEW this number and write the timestamp into a file. Unfortunately, I couldn't find an easier way to get this number, since there are no 64-bit integer data types in LabVIEW.

You can run the vi, it will ask for a file name. Looking in the newly created file you will get the above number in HEX and in big-endian format.

It's curious google doesn't give this number.

I hope this time it's right.

-Cengiz

QUOTE (JackHamilton @ Jan 8 2004, 12:04 PM)
clock.gif
Here is a VI that outputs all three time references Jan 1, 1904, 1970 & 1980. Keep in mind that the LabVIEW "Seconds to Date & Time" will not resolve the date correctly for the 1970 and 1980 reference.

This VI does not simply subtract 66 years, but calls the time convert function in LabVIEW which (*should*) perform all the proper timezone and leap year adjustments.

You should see the today's date in the 1904 reference, the same time but 1970 in the 1970 box and etc for the 1980 box.

Good Luck.
*


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
rolfk
post Aug 12 2005, 07:27 AM
Post #6


<customize this text>
*****

Premium Member
Posts: 1060
Joined: 9-April 04
From: Rotterdam
Member No.: 349
Using LabVIEW Since:1992
LV:8.5.1 ,8.2.1 ,7.1.1
Netherlands Switzerland Nothing Selected


QUOTE (cengique @ Aug 10 2005, 03:07 PM)
Sorry but your VI outputs the wrong times. You really need to calculate the number of seconds elapsed between the 1904 date and 1970 date. Simply subtracting the year doesn't solve the problem.

Anyway, in my case I needed that number of seconds to subtract to adjust the 1904-based mac date to 1970-based unix date. The value above in the first message of the thread gave me a 16-day offsetted date. So I calculated my own number: 2082816000. This is the number of seconds elapsed between 1/1/1904 and 12pm 12/31/1969. I used the attached VI Attached File  Time_conversion.vi ( 18.83K ) Number of downloads: 857
to ask LabVIEW this number and write the timestamp into a file. Unfortunately, I couldn't find an easier way to get this number, since there are no 64-bit integer data types in LabVIEW. 

You can run the vi, it will ask for a file name. Looking in the newly created file you will get the above number in HEX and in big-endian format.

It's curious google doesn't give this number.

I hope this time it's right.

-Cengiz
*


I think you made a significant mistake in the calculation as you did not take into account your current time zone offset. I am not entirely sure this calculation holds true either but the result of 2082840000 would be more appropriate assuming both reference dates are supposed to be GMT which in general is the right thing. If you calculate the the quotient and remainder from this number with 86400 you get a quotient of 24107 and a remainder of 0, indicating that there are indeed exactly a full number of days in between.

Attached is the diagram of the VI I used to calculate that offset. This should be independent of the time zone you are in.

This post has been edited by rolfk: Aug 12 2005, 07:32 AM
Attached image(s)
Attached Image
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
monzue
post Nov 3 2008, 11:16 PM
Post #7


Enough LAVA to be dangerous


Member
Posts: 4
Joined: 5-February 07
From: HSV, AL
Member No.: 7683
Using LabVIEW Since:2006
LV:8.20 ,. ,.
us_alabama Nothing Selected Nothing Selected


I know this is an old thread, But I am amazed at all the numbers thrown around in this posting that are incorrect.

Just in case you need to know, and don't want to work it out for yourself, the number of seconds elapsed between the first days of 1904 and 1970 is 2082844800.


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

 




Time is now: 9th January 2009 - 12:11 AM