Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active May 26, 2023 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/8d3dcf352682ca73c34d98d7601f1145 to your computer and use it in GitHub Desktop.
Save justinyoo/8d3dcf352682ca73c34d98d7601f1145 to your computer and use it in GitHub Desktop.
Converting Tick or Epoch to Timestamp in Logic App
{
"token_type": "Bearer",
"access_token": "[ACCESS_TOKEN_VALUE]",
"expires_on": "1536543296",
"not_before": "[ANOTHER_EPOCH_VALUE]"
}
ConvertEpochToTimestamp:
type: Compose
runAfter:
GetTimestampInEpoch:
- Succeeded
inputs:
timestamp1: "@addToTime('1970-01-01T00:00:00Z', 1536543296, 'Second')"
timestamp2: "@addSeconds('1970-01-01T00:00:00Z', 1536543296)"
GetTimestampInEpoch:
type: Compose
runAfter:
GetTimestampInTicks:
- Succeeded
Get1970TimestampInTicks:
- Succeeded
inputs:
epoch: "@div(sub(636721400967890200, 621355968000000000), 10000000)"
ConvertTicksToTimestamp:
type: Compose
runAfter:
GetTimestampInEpoch:
- Succeeded
inputs:
timestamp: "@addToTime('1970-01-01T00:00:00Z', outputs('GetTimestampInEpoch').epoch, 'Second')"
GetTimestampInTicks:
type: Compose
runAfter: {}
inputs:
ticks: "@ticks('2018-09-10T12:34:56+11:00')"
Get1970TimestampInTicks:
type: Compose
runAfter: {}
inputs:
ticks: "@ticks('1970-01-01T00:00:00Z')"
GetTimestampInEpoch:
type: Compose
runAfter:
GetTimestampInTicks:
- Succeeded
Get1970TimestampInTicks:
- Succeeded
inputs:
epoch: "@div(sub(outputs('GetTimestampInTicks').ticks, outputs('Get1970TimestampInTicks').ticks), 10000000)"
GetTimestampInTicks:
type: Compose
runAfter: {}
inputs:
ticks: "@ticks('2018-09-10T12:34:56+11:00')"
@navneettrehan
Copy link

Really nice!! working for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment