What is the UTCToday Function?
The UTCToday function in Power Fx returns the current date and time in Coordinated Universal Time (UTC). UTC is a standard time used worldwide, so it’s useful in situations where you need to have a consistent time across different time zones.
How to Use the UTCToday Function in Power Apps
Using the UTCToday function in Power Apps is pretty straightforward. Here’s how you can use it:
1. Open Power Apps and create a new canvas app.
2. Add a new screen to your app and name it.
3. Add a label to the screen and name it “Current UTC Time”.
4. Select the label, and in the formula bar, type “UTCToday()”.
5. Press Enter to apply the formula to the label.
6. Save and preview your app.
That’s it! You should now see the current UTC time displayed on the screen.
Additional Options for Using the UTCToday Function
In addition to displaying the current UTC time, you can also use the UTCToday function for other purposes. Here are a few examples:
Displaying the Local Time
If you want to display the local time instead of UTC time, you can use the TimeZoneOffset function along with UTCToday. Here’s how:
1. Add a new label to the screen.
2. In the formula bar, type “UTCToday() + TimeZoneOffset()”.
3. Press Enter to apply the formula to the label.
4. Save and preview your app.
Now you should see the local time displayed on the screen.
Performing Calculations with Time
The UTCToday function can also be used for performing calculations with time. For example, if you want to find out how many hours have elapsed between two dates, you can use the DateDiff function along with UTCToday. Here’s how:
1. Add two date pickers to the screen.
2. Add a button to the screen and name it “Calculate”.
3. Select the button, and in the formula bar, type “DateDiff(StartDatePicker.SelectedDate, EndDatePicker.SelectedDate, Hour) “.
4. Press Enter to apply the formula to the button.
5. Save and preview your app.
Now when you select a start and end date and click the “Calculate” button, you should see the number of hours between the two dates displayed.
In this article, we discussed the Power Fx UTCToday function and how to use it in Power Apps. We covered the basic usage as well as a few additional options for using the function. By using the UTCToday function, you can ensure that your app is displaying consistent time across different time zones.