Example Code

LabVIEW Timestamp to Universal Timestamp in C++

Code and Documents

Attachment

Introduction

When performing data acquisition in C++ or other text based languages, there is no waveform datatype like that in LabVIEW. Acquired data is returned as an array of values. For programs where data has to be passed between LabVIEW and these textbased ADE's, it is possible to make sure that the timestamps agree using this conversion program.

The time stamp data in LabVIEW is the number of seconds elaped since 12am, Friday, January 1, 1904, Universal Time. However, working in C++ and trying to get the timestamps to agree, I found that the C++ values were the number of seconds elapsed since 00:00:00 on January 1, 1972, Coordinated Universal Time.

The code contained in this VI converts the LabVIEW timestamp to vales that matched the C++ timestamps.

univeral time.png

Mallori M
National Instruments
Sr Group Manager, Education Services

ni.com/training

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
prcngwsas
Member
Member
on

Isn't the Unix epoch ( start date 0) actually Jan1 1970 at 12:00:00

The Unix epoch (or Unix time or POSIX time or Unix  timestamp) is the number of seconds that have elapsed since January  1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601:  1970-01-01T00:00:00Z).  Literally speaking the epoch is Unix time 0 (midnight 1-1-1970), but  'epoch' is often used as a synonym for 'Unix time'.  Many Unix systems store epoch dates as a signed 32-bit integer, which  might cause problems on January 19, 2038 (known as the Year 2038 problem  or Y2038).

Contributors