From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

ISO-8601 compliant date/time string in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example transforms the input date and time to ISO 8601 Standard

 

Description

This example creates an ISO-8601 compliant date/time string using various LabVIEW format specifiers. If no timestamp is provided, the current time is used.

 

Requirements

LabVIEW Full Development System 2012 or compatible

 

Steps to Implement or Execute Code

  1. Enter the Date and Time Part in the same format as indicated
  2. If no date and time is entered the current time will be used
  3. Select whether to show the Time Zone, Basic or Zulu
  4. Run the VI 

Additional Information or References

 Wikipedia entry for ISO-8601

VI Block Diagram

7199.PNG

 

 SubVI Connector Pane

8601 UTC Date-Time String.png

 

**This document has been updated to meet the current required format for the NI Code Exchange. **


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

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

Comments
GerdW
Knight of NI Knight of NI
Knight of NI
on

Hi Phillip,

there's a bug in your VI related to how LabVIEW numbers weeks of year. The LabVIEW numbering scheme uses US-american standard which is different to ISO8601! You can test that with a date like Jan 3rd 2010 (as noted in the linked Wikipedia entry, section "Week dates")...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
PhillipBrooks
Active Participant
Active Participant
on

Wow! Thanks for catching that. I'm gonna try to fix that up, but it seems I have to do more of the work that LV should have done for me


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

GerdW
Knight of NI Knight of NI
Knight of NI
on

Hi Phillip,

go here: http://forums.ni.com/t5/LabVIEW/Date-time-conventions/m-p/172136#M101086 to find a correctly working ISO-Week VI!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
PhillipBrooks
Active Participant
Active Participant
on

GerdW, I used the example you referenced. I changed the design of my VI to use a state machine, and had to add some logic to the referenced VI to update the year.

Lesson learned: LabVIEW 'to UTC' ≠ ISO-8601 compliant


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

PhillipBrooks
Active Participant
Active Participant
on

The VI I created offers many variants of an 8601 string, but you can use the following format string with "Format into String" and "Scan from String" to persist an 8601 UTC timestamp.

%^<%Y-%m-%dT%H:%M:%S%3uZ>T


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

J.CHEN
Member
Member
on

More developement work has been done here and shared as open source project. A very comprehensive set of time zone libraries. You can also find the package via JKI VI Package manager by searching for "Epoch"

 

https://github.com/LabVIEW-Open-Source/Epoch-Time