LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change labview timestamp epoch to UTC epoch

Solved!
Go to solution

hi,

      i have database table in UTC epoch field.i want to select  and insert data from database table based on labview timestamp controll.

 

    example:

                       table:

                                   S:no      U.name         PWD                Epoch(UTC 1970)

 

                                    1           kumar            123                 1450422341

                                    2           sham              786                 1450421623

 

the labview epoch is difference from UTC epoch. so ADD this  second 2082844800 to  labview epoch than it will work for selection quary but insert epoch is not work.

 

 

0 Kudos
Message 1 of 11
(10,099 Views)

UTC is essentially just a timezone - it doesn't have an 'epoch' (well... year 0 in gregorian calendar). Unless you mean the Unix epoch?

 

The LabVIEW timestamp starts at 01/01/1904 00:00:00.00 UTC

The unix epoch is 01/01/1970 00:00:00.00 UTC

 

(Note how both times are expressed in UTC!)

 

 

If you use the 'timestamp to number' VI, it will convert the LabVIEW timestamp into the number of seconds since the LabVIEW start time. You can then add the 66 years worth of seconds to it to convert it to the Unix epoch.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 11
(10,079 Views)
Solution
Accepted by GokulGKM

Here is how I convert a LabVIEW time stamp to an Excel (OLE) timestamp.

 

Timeconvert.png

Red the explainiation at the bottom and I am sure you can figure out how to change it to get use Epoch you need. 

========================
=== Engineer Ambiguously ===
========================
Message 3 of 11
(10,052 Views)

An example of converting a LabVIEW timestamp to a *NIX # seconds since Jan 1,1970  can be found here (even with LV 8.2 download!)

 

https://decibel.ni.com/content/docs/DOC-3644

 

 I would avoid using the kernel32.dll example and try creating the example I provided at the bottom. I used LabVIEW 2011 for the example, don't have 8.2 installed.


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 4 of 11
(10,039 Views)

Well, Time 2 Excel rides again! Capture.PNG

 

The Only problem with that vi.... DAMNED timestamp constants!  Whitch is exactly what I feel you are hitting..... Timestamp constants do not travel well! they are tied to the system time settings.  Don't get me wrong! that little vi has over a dozen solved threads on these forums!  Its just that you need to pick a timezone for all of the target machines.  Set them ALL up for UTC! Then, everybody plays along nice.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 11
(9,943 Views)

@JÞB wrote:

Well, Time 2 Excel rides again

 

The Only problem with that vi.... DAMNED timestamp constants!  Whitch is exactly what I feel you are hitting..... Timestamp constants do not travel well! they are tied to the system time settings.  Don't get me wrong! that little vi has over a dozen solved threads on these forums!  Its just that you need to pick a timezone for all of the target machines.  Set them ALL up for UTC! Then, everybody plays along nice.


While you make some valid points, try explaining to my manager why the timestamps are all eight or nine hours off.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 11
(9,938 Views)

@RTSLVU wrote:

@JÞB wrote:

Well, Time 2 Excel rides again

 

The Only problem with that vi.... DAMNED timestamp constants!  Whitch is exactly what I feel you are hitting..... Timestamp constants do not travel well! they are tied to the system time settings.  Don't get me wrong! that little vi has over a dozen solved threads on these forums!  Its just that you need to pick a timezone for all of the target machines.  Set them ALL up for UTC! Then, everybody plays along nice.


While you make some valid points, try explaining to my manager why the timestamps are all eight or nine hours off.


Windows


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(9,929 Views)

thank you 

0 Kudos
Message 8 of 11
(9,324 Views)

Paul Cardinale posted this nifty tidbit that calculates UTC offset a while back.utc offset.png

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 11
(9,305 Views)

For Python users, the DST needs to be set to (0) Standard to convert LabVIEW's local time zone to Python's local time zone using:

 

from datetime import datetime

datetime.fromtimestamp(unix_utc_seconds)

 

This way the default settings in Python's datetime will resolve to the local time zone successfully.

 

LabVIEW_to_Unix_UTC_Seconds.png

0 Kudos
Message 10 of 11
(418 Views)