- 12 Mar 2021
- 2 Minutes to read
- Print
- DarkLight
Epoch and Unix Timestamp Conversion
- Updated on 12 Mar 2021
- 2 Minutes to read
- Print
- DarkLight
Overview
Example Lab Details | |
Version | 6.4.0 |
Root Folder | Example Lab - Unix Time Converter |
Modules | None |
Dependencies | None |
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.