Search code examples
powerappspowerapps-formula

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

Solution

    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.