Example Code

Alternative Convert String to Timestamp Using 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

Description

Overview
The example VI shows how to use the Numeric Text .Text property of a Time Stamp to change a compatible string directly into a Time Stamp.


Description
In the example below, the Format String property is used to set the expected format of the string for the conversion into a Time Stamp.  Another option would be to use the Properties dialog box to customize the string format for the Time Stamp for easy modification depending on your string input, without needing to work directly with the format codes for Time Stamps (found at the link below in the steps section).


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Create a Time Stamp control or indicator.
  2. Right-click the Time Stamp control or indicator and select Create>>Property Node from the dropdown menu.
  3. Left-click the property to change it with a dropdown menu to Numeric Text>>Text.
  4. Right-click the Property Node and select "Change All to Write" from the dropdown menu.
  5. Use one of two options to customize the format of the input string:
    1. Programmatically define the string format:
      1. Drag down the bottom edge of the Property Node to add an additional property. 
      2. Change this property to FormatString. 
      3. Wire a string of Format Codes to the Format String property based on the codes found here:  https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/vi-lib/string/format-codes-for-the-time-fo...
    2. Define the string format using the Properties Dialog box:
      1. Right-click the Time Stamp control or indicator and select Properties from the dropdown menu.
      2. Navigate to the Format tab and customize the formatting using the interactive options (see the second image below).

 

Additional Information or References

snippet有问题使用截图.png

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

Highest Regards,

Paul

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