How to convert a local datetime to UTC in Power Apps

Hello everyone and welcome to my blog. In today’s blog I will show how you can convert a local DateTime to UTC time.

Let’s get started. If you are from traditional programming, you will find constructs like ConvertToUTC or something similar. In Power Apps however, you don’t have any sort of function like that.

Rather, Power Apps has a function TimeZoneOffset using which we can convert local time to UTC in Power Apps.

In the above screen shot, I have set the text of the label to Now() which prints the local datetime. I want to convert it to UTC time. For reference, my timezone is UTC+5:30

I use the below code to convert the local time to UTC time.

DateAdd(
    Now(),
    TimeZoneOffset(),
    TimeUnit.Minutes
)

And below is the output.

Hope this helped.

Debajit


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading