ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

取消
显示结果 
搜索替代 
您的意思是: 

VI to convert LabVIEW time to Unix time

Does anybody know of a VI to convert LabVIEW time to Unix time?
0 项奖励
1 条消息(共 16 条)
31,308 次查看
There aren’t any VIs already available to convert LabVIEW time into Unix time. Currently, the LabVIEW Get Date/Time in Seconds.vi returns a time stamp of the current time, measured as the number of seconds that have elapsed since 12:00 a.m., January 1, 1904, Universal time. As far as I know, the unix timestamp is based on seconds since standard epoch of 1/1/1970. The conversion to unix time would not be too difficult; essentially you would just want convert timestamp all to seconds and then subtract the number of seconds from 1904 to 1970.

An alternative approach would be to see if there’s a shared library (or DLL equivalent) on the unix OS that will return the unix time.

Hope this helps. Best of luck!

Kileen
0 项奖励
2 条消息(共 16 条)
31,290 次查看
This could be an entertaining project. I think times are stored based on GMT, then there is an offset local to your computer which puts the sun in the right part of the sky, for where you are. At least it seems that way with Microsoft time. Is Unix time really POSIX time? I see a POSIX manual at the very end of my bookshelf...

Time is number of seconds since midnight January 1, 1970
    Coordinated Universal Time
(GMT). It would be interesting to find out how to discover the timezone offset of the local computer; it seems like its hardware specific.
0 项奖励
3 条消息(共 16 条)
31,288 次查看

I've created a VI that does just this and posted it on the community examples. You can view it at http://decibel.ni.com/content/docs/DOC-3644.

 

Basically to get around the timezone issue that Odd_Modem pointed out it queries the timezone data from the kernel32.dll in windows then subtracts out this offset.

 

Regards,

 

Steven Zittrower

Applications Engineer

National Instruments

http://www.ni.com/support

0 项奖励
4 条消息(共 16 条)
30,562 次查看

StevieZ, I don't believe your method is necessary.  That is, there isn't a "time zone" issue to deal with.  I've attached a VI that demonstrates this.

UNIX_Time_Simple.jpg

5 条消息(共 16 条)
30,214 次查看

Here is a simpler (and OS independent) method to get the timezone offset.

CalcOffset.png

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
6 条消息(共 16 条)
30,187 次查看
Very nice, Ton.  But what I'm attempting to demonstrate is that the timezone offset is not needed if one is simply trying to determine the current Unix (POSIX) time.  All that is needed is to subtract a constant, timezone independent value from the LV timestamp.
7 条消息(共 16 条)
30,143 次查看

ceger wrote:
Very nice, Ton.  But what I'm attempting to demonstrate is that the timezone offset is not needed if one is simply trying to determine the current Unix (POSIX) time.  All that is needed is to subtract a constant, timezone independent value from the LV timestamp.

Indeed and you can determine that offset once and then use it as a simple numeric in all your diagrams.

 

For the curious ones the interesting part that ceger refers to is all at the right border of his VI in the box. What you see there is all that is needed to convert LabVIEW time from its epoch into a different epoch.

Message Edited by rolfk on 10-13-2009 08:09 AM
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 项奖励
8 条消息(共 16 条)
30,129 次查看

ceger wrote:
Very nice, Ton.  But what I'm attempting to demonstrate is that the timezone offset is not needed if one is simply trying to determine the current Unix (POSIX) time.  All that is needed is to subtract a constant, timezone independent value from the LV timestamp.

Yes I know, I was posting the code to provide a non-os dependent way to get the timezone offset.

Especially since the Windows version came from an NI member.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 项奖励
9 条消息(共 16 条)
30,123 次查看

Hi,

I need information for convert LV Date/Time to Unix time on sbRIO9631.

I have seen the example, but I have a different time between PC and sbRIO (sbRIO: 2010/04/09 07:22:33 and PC: 2010/04/09 16:22:33).
I need to synchronize the time!

If anyone can help?


Thanks a lot!

 

md71

0 项奖励
10 条消息(共 16 条)
29,393 次查看