LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Unix timestamp to LabVIEW time

Solved!
Go to solution

Hello

I need to convert a Unix timestamp comming froma dll to a LabVIEW time. Does anybody now some ready to use function for this?

Thanks

 

Message 1 of 5
(6,307 Views)
Solution
Accepted by topic author DAckermann

What is the datatype of the unix timestamp?

 

The epoch of unix is 1/1/1970.

The epoch of LabVIEW is 1/1/1904

 

All you need to add is the number of seconds between the two epochs (i.e. the value of a LabVIEW timestamp of 1/1/1970)

Message 2 of 5
(6,304 Views)

Oh yes. That was easy.

 

Thank you very much!

0 Kudos
Message 3 of 5
(6,250 Views)

@DAckermann wrote:

Oh yes. That was easy.

 

Thank you very much!


Exceot that there is a small possible gotcha. If you enter 1/1/1970 in a LabVIEW timestamp control and convert this to a double to get the number of seconds you likely end up with an error of your local timezone offset.

Both the Unix and LabVIEW epoch are defined respective to GMT which for most practical purposes is the same as UTC. So you have to make sure to get the number of seconds for a timestamp that shows 1/1/1970 00:00 UTC to be right.

 

Spoiler
If you ended up with 2082844800 as offset then you got it right.
Rolf Kalbermatter
My Blog
Message 4 of 5
(6,201 Views)

I cannot express how much this little hint means to me. Thank you so much!

 

Here is a screenshot of a TimeStamp Constant, where I changed the Display Format to show UTC and then the magical 1h appeared. It haunted me for days, that my data appeared to be in the future in my database, when I was sending the Time as a UNIX Timestamp.

0 Kudos
Message 5 of 5
(71 Views)