LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about converting time stamp to double

Hello, All, 

       I'm a little confused about how timestamp to Double conversion works. Could someone explain to me a little bit. I was doing a test to convert the timestamp to unix time. The snapshot is attached.

       I set the timezone of my PC to UTC and run the VI with LabView2017.  The time on my Windows is showing 7:33PM, the unixsec I get is 1501857207, which converts to GMT Friday, August 4, 2017 2:33:27 PM. 

       I wonder why there is 5 hour difference. 2:33PM is the actual local time here(GMT-6)

Thanks

        

 

 

0 Kudos
Message 1 of 9
(3,752 Views)

@MMCCOIN wrote:

 

       ... (snapshot attached) ...


I don't see any attachments.

0 Kudos
Message 2 of 9
(3,742 Views)

Sorry. I was editing the post, as I noticed that it behaves the same on Windows and RT-OS

0 Kudos
Message 3 of 9
(3,737 Views)

Are you adjusting for your time zone properly? Try this:

Timeconvert.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 9
(3,713 Views)

Thanks. I wonder where Labview grabs Timezone info. I changed timezone in Windows time settings as UTC, but  it still shows Central Daylight Time when I run the VI on my PC.  I also did a test on CRIO. I set CRIO as UTC through  NI Max, and run the VI,  it shows UTC.

0 Kudos
Message 5 of 9
(3,699 Views)

One thing I found is that LabVIEW only looks at the timezone when it first loads.  If you change the timezone in the midst of having the development environment open, it won't immediately realize it.  You will need to close and reopen LabVIEW before it sees the change.

0 Kudos
Message 6 of 9
(3,692 Views)

I think you avoid this whole issue if you subtract before you convert?

 

oops I mean the issue with worrying about conversion to double.

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 9
(3,622 Views)

Thanks. I figured it out. When converting to double, it is the total seconds from Labview Epoch to local time. In my code, I made a mistake on the constant that converts Labview Epoch Unix Epoch. 

0 Kudos
Message 8 of 9
(3,579 Views)

I use globals like this so it is a little more self-documenting:

epoch time.pngglobals.PNG

(Be aware that, due to the forum software formatting the picture for display, this is no longer a valid snippet.  Download the file provided, instead.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(3,573 Views)