cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Tima Date format to UNIX Timestamp

I have an HTTP webhook that I post to that requires me to send the event date in UNIX Timestamp. I'd like a function (like I use utcnow() for several flows) or a connector that can do that.

Status: New
Comments
Level: Powered On

Your idea is good, Flow should support UNIX/Epoch Timestamps.

 

In the meantime, suggest you look at this solution to accomplish your task:

https://powerusers.microsoft.com/t5/Building-Flows/Got-a-recipe-for-converting-a-unix-timestamp-to-a...

Level: Powered On

This should work:

div(sub(ticks('2019-04-10'),ticks('1970-01-01')), 10000000)

Ticks are in units of 100 nanoseconds... so divide by 10000000 to get seconds.

 

Cheers!

 

Joel

--

https://joelblogs.co.uk

Level: Power Up

@joelblogs idea almost works. It should be ticks x 10,000 and I'd use utcNow for current time so, this will work:

 

div(sub(ticks(utcNow()),ticks('1970-01-01')), 10000)
Level: Powered On

@MrBizDevOps  Doesn't that depend upon if you want your timestamp in seconds, milliseconds or microseconds? 

ticks() returns nanoseconds, which you need to divide by 10^9 to convert to seconds.

 

My answer gave timestamp in seconds. Doesn't yours give it in microseconds?

 

There are several formats of UNIX timestamp, including the above three. Seconds is the most used format though. 

 

This should still be the most common right answer... and has been working for me Smiley Wink 

div(sub(ticks(utcNow()),ticks('1970-01-01')), 10000000)

 


 

Level: Power Up

@joelblogs good points of clarification! I followed another thread to get here where they were looking for milliseconds using https://currentmillis.com/ but in all the link jumping, I didn't realize this post was not as specific!

 

I think that as long as users understand that depending on their need, they can get the right UTC time in seconds, milli, etc by changing the multiplier, this addresses the need. In APM tools like Dynatrace for example, because they focus on crunching data for events tracked down to the millisecond, the standard (and required) there is UTCmilli.