You are viewing limited content. For full access, please sign in.

Question

Question

convert to timestamp or epoch

asked on March 1, 2024

Is there a way in Workflow 11 to convert a date or date time to timestamp or epoch? I'm trying to integrate a process with a 3rd party api and it only accepts timestamp or epoch values.

0 0

Answer

SELECTED ANSWER
replied on March 13, 2024

Good afternoon Cassandra

 

Have you tried using the token calculator with this formula? 

DATEDIF(Date(1970,1,1) , %(Date), "D") * 86400



Given today's date of 2024-03-13, the answer 1710288000 appears to be correct when checked against this online tool: https://www.epochconverter.com/

(add 3 more zeros on the end for the millisecond version)

Let me know if that works.

Thank you

1 0

Replies

replied on March 3, 2024

Hello Cassandra

Can you provide an example of what format exactly the 3rd party API is expecting? There are a number of functions in Workflow for DateTime format conversions. Input/Output examples would be great. 

Thank you

0 0
replied on March 6, 2024

Yes, the API would expect epoch "1701061200000" if Date was 11/27/2003. Workflow Token Calculator can convert an epoch time to date but not the reverse.

0 0
replied on March 6, 2024

There is this Answers post from 2019 but was hoping there had been an update to Workflow since this that included the functionality.

 

https://answers.laserfiche.com/questions/166825/timestamp

0 0
replied on March 10, 2024

Good morning Cassandra

You are correct that Workflow has a built-in function for Epoch to Date, that works with timestamps to the second, but there is not function for doing this in reverse. 

Based on your example above, you are looking to convert only the Date portion of a DateTime item to unix ticks, correct? It also appears that the API is expecting the millisecond version of the timestamp, correct?

Thank you

0 0
replied on March 11, 2024

I can do Date or DateTime - either will work. The API will return a millisecond result but does not require one to be sent. It will just assume 0 if none is provided.

0 0
SELECTED ANSWER
replied on March 13, 2024

Good afternoon Cassandra

 

Have you tried using the token calculator with this formula? 

DATEDIF(Date(1970,1,1) , %(Date), "D") * 86400



Given today's date of 2024-03-13, the answer 1710288000 appears to be correct when checked against this online tool: https://www.epochconverter.com/

(add 3 more zeros on the end for the millisecond version)

Let me know if that works.

Thank you

1 0
replied on March 18, 2024

That works great! Thank you so much :D

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.