Skip to main content
June 24, 2024
Question

Convert Current time to millisecond

  • June 24, 2024
  • 3 replies
  • 1 view

Convert current time to milliseconds.

Ex. 1719220373569 (5:13 pm in China)

Any idea, how we can achieve this in Appian? Any function or plugins?

3 replies

konduruc733182
June 24, 2024

Hello [mention:91b571e57a1b4955866bb7c22118f899:e9ed411860ed4f2ba0265705b8793d05] 

This would be epoch time conversion. Below is a calculation which would work perfectly given your timezone is set to HKT.

 tointeger(
   (
     todatetime(ri!dateTime) - todatetime("01/01/1970")
   ) * 24 * 60 * 60
 )

June 26, 2024

Thanks [mention:2df2892a4df7486f9775b4d2f0e405fd:e9ed411860ed4f2ba0265705b8793d05] , yes it works.

I used below code.

  localvariables(
  local!unixEpoch : fn!datetime(1970, 1, 1, 0,0,0,0),
  local!intervalDiff: now() - local!unixEpoch,
  local!stringintervalDiff: fn!tostring(local!intervalDiff),
  local!days: fn!tointeger(local!intervalDiff),
  local!stringPartExcludingDays: fn!split(local!stringintervalDiff, "::")[2],
  local!splitPartExcludingDays: fn!split(local!stringPartExcludingDays, ":"),
  local!hours: fn!tointeger(local!splitPartExcludingDays[1]),
  local!minutes: fn!tointeger(local!splitPartExcludingDays[2]),
  local!seconds: fn!tointeger(local!splitPartExcludingDays[3]),
  local!milliseconds: right(local!splitPartExcludingDays[3], 3),
  fixed(
    (local!days * 24 * 3600) + (local!hours * 3600) + (local!minutes * 60) + local!seconds,
    0,
    true
  ) & local!milliseconds
)

stefanhelzle0001
June 26, 2024

There is a plugin providing that function.

 [mention:d7ae9642523840f797e96e47dbfa6bae:f7d226abd59f475c9d224a79e3f0ec07]