Lucas Sousa
Lucas Sousa

Reputation: 411

How to convert a Date value to unix timestamp?

Is there a simple way to convert a Date value to the UNIX timestamp in PowerApps?

For example:

UNIX(Today()) // -> 1583722800000
//Or
UNIX(Date(2020, 03, 09)) // -> 1583722800000

Upvotes: 1

Views: 2325

Answers (2)

mweber
mweber

Reputation: 688

Another way would be to use the ticks difference:

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

gives current time in seconds from 1970/01/01.

Upvotes: 0

Lucas Sousa
Lucas Sousa

Reputation: 411

  1. You can actually just use the Text() function with the format param:
Text(Date(2020, 03, 09), "") // -> 1583722800000
  1. You just calculate the DateDiff from January 1st 1970:
DateDiff(Date(1970, 01, 01), Date(2020, 03, 09), Milliseconds) // - Timezone Offset
// -> 1583722800000

But be careful as this case will take your timezone in account.

Upvotes: 3

Related Questions