Epoch and Unix Timestamp Conversion
  • 12 Mar 2021
  • 2 Minutes to read
  • Dark
    Light

Epoch and Unix Timestamp Conversion

  • Dark
    Light

Article summary

Example Lab Article
While Example Lab projects are resources for public use, articles and assets are not actively maintained. Screenshots and features are from the specified version below. These references may become dated as new versions are released.


Overview

Example Lab Details

Version6.4.0
Root FolderExample Lab - Unix Time Converter
Modules None
DependenciesNone

This Example Lab project demonstrates how to convert a Unix Epoch timestamp to standard human-readable date and time format.


Explanation

In this project, the user will be required to enter a timestamp in the Unix Epoch format to begin the Flow. The first step "Get String Length" will output the length of the string that was entered by the user and pass it into the next step. The "String Match" Step will then check to see if the length of the string is equal to 10, 13, or neither. 

In the case where the string length is equal to 10, the original user input string will be converted to data type Int64 using the conversion Sub Flow "Convert string to Int64". The converted output is then passed into the "From Unix Time" where the Unix timestamp is converted to standard date and time format. The converted date is then displayed to the user in a popup window.

In the case where the string length is equal to 13, the original string would be passed to the "Raw SQL Step". In this example, the SQL query run calculates the addition of two date formats, seconds since the date January 1st, 1970 plus the date January 1st, 1970. The output from this step is then passed to the "Create Data" step which converts the output to standard date and time format. The converted date is then displayed to the user in a popup window.

In the case where the string length is not equal to 10 or 13, the string will be passed to the "Round" step where the step will attempt to round the number up. Once the number has been rounded the string length will be checked again and if it now equals 10 or 13 the Flow will skip to the conversion steps appropriate for the corresponding string length. 

Reference Articles




Project Download

The examples attached were developed to be instructional and were not developed as officially supported components. For more information or to engage our service team to develop fully supported, production quality solutions, please contact services@decisions.com. Import the project below to a Decisions environment on version 6.4.0 or later using our Importing/Exporting article.





Was this article helpful?