LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a UTC timestamp?

Solved!
Go to solution

Hi sorin,


@sorin1 wrote:

For example, if UTC date&time is March 26, 2020 16:50:04 (UTC), the value is 3668086204 seconds


Like this?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 19
(2,087 Views)

yes, but I need to get current date/time from PC (UTC, not local) and then converts it into seconds

0 Kudos
Message 12 of 19
(2,083 Views)

Hi sorin,

 


@sorin1 wrote:

yes, but I need to get current date/time from PC (UTC, not local) and then converts it into seconds


Get current time from PC and subtract offset to UTC.

You get the offset by comparing the result of the timestamp to time cluster conversion with/without UTC flag or by using the %z formatcode when converting a timestamp to a string…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 19
(2,079 Views)

@sorin1 wrote:

yes, but I need to get current date/time from PC (UTC, not local) and then converts it into seconds


Then just use the Get Date/Time In Seconds and convert to a DBL.  The timestamp's data is in UTC.  The display will, by default, match the system format.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 19
(2,076 Views)

Please GerdW, could you post an example? thanks

0 Kudos
Message 15 of 19
(2,075 Views)

@sorin1 wrote:

Please GerdW, could you post an example? thanks


Here's what I was saying.  The timestamp control shows the system time zone, but the data is still UTC.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 19
(2,068 Views)

Hi,

 

I extracted the following solution from here

Get UTC Time Stamp.png

 

Regards

Vinay

0 Kudos
Message 17 of 19
(1,999 Views)

Keeping your log files with UTC timestamp erases any DST ambiguities and other weirdness, like: what happens in the fall when you have two sets of data between 0100 and 0200, and in the spring when you will have a hole between 0200 and 0300?

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 18 of 19
(1,976 Views)

@billko wrote:

Keeping your log files with UTC timestamp erases any DST ambiguities and other weirdness, like: what happens in the fall when you have two sets of data between 0100 and 0200, and in the spring when you will have a hole between 0200 and 0300?


The last system I did, I just kept the system on UTC (set time zone to UTC).  Much easier to manage then.  It also helped to synchronize with my UUT since it kept a UTC time.  I got really good at subtracting 4 or 5 hours in my head to convert to EDT or EST.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 19 of 19
(1,967 Views)