Select to view content in your preferred language

Quick Tip: Convert Epoch Time to a Human Readable Date Format

3538
8
05-11-2022 06:54 AM
SeanKMcGinnis
Esri Contributor
2 8 3,538

First, we should understand what epoch time is. Epoch time is also known as Unix time, which is the number of seconds that have passed since 0:00:00 January 1st, 1970. So to get the time/date stamp, we need a way to add these seconds to January 1st, 1970. Lucky for us, Power Automate includes the 'addSeconds' expression that will do the heavy lifting for us for us. Below is an example of using the addSeconds expression.

 

 

addSeconds('1970-1-1', 'Epoch Timestamp', 'MM/dd/yyyy')

 

 

addSeconds - the name of the Power Automate expression doing the conversion

'1970-1-1' - the start of the epoch and what we will add the seconds to

'Epoch Timestamp' - this is the variable being passed into the expression. This expression expects the value to be an integer representing the number of seconds since 1970-1-1

'MM/dd/yyyy' - this is the ISO defined output format the user wants to represent the timestamp in. Either a single format specifier character or a custom format pattern that indicates how to format the value of this timestamp. If format is not provided, the ISO 8601 format ('o') is used. This is customizable to meet the needs of your date/time representation.

The first action is the Epoch time representation of May 11th, 2022. The second shows the expression to set the variable.The first action is the Epoch time representation of May 11th, 2022. The second shows the expression to set the variable.

NOTE: If you are working with values that are coming from a timestamp in a feature layer, the value returned is in milliseconds. Before passing it into the 'addSeconds' expression, divide the value by 1000.

8 Comments