TimeZoneOffset

How to Use the Power Fx TimeZoneOffset  Function in Power Apps

Introduction to TimeZoneOffset Function

The TimeZoneOffset function is used to convert the date and time values to the user’s local time zone. This function can be used in various scenarios, such as displaying dates and times in a particular time zone, scheduling appointments, and calculating the difference between two time zone values.

The TimeZoneOffset function returns the difference between the local time zone and the UTC time zone in minutes. In other words, if the user is in the UTC -5 time zone, the function will return the value -300 (5*60). If the user is in the UTC +5 time zone, the function will return the value 300 (5*60).

How to Use TimeZoneOffset Function

The TimeZoneOffset function can be used in any expression in Power Apps. The syntax for the TimeZoneOffset function is:


TimeZoneOffset(Now())


This expression returns the difference between the local time zone and the UTC time zone for the current date and time.

To use the TimeZoneOffset function in a text input control, add the following expression to the Default property:


Now() + (TimeZoneOffset(Now()) / 1440)


This expression adds the difference between the local time zone and the UTC time zone to the current date and time and converts the result into the user's local time zone.

To use the TimeZoneOffset function in a label control, add the following expression to the Text property:


Text(Now() + (TimeZoneOffset(Now()) / 1440), “[$-en-US]dd/mm/yyyy hh:mm:ss AM/PM”)


This expression converts the current date and time into the user's local time zone and formats the result as a date and time string.

In conclusion, the TimeZoneOffset function is a powerful tool for displaying dates and times in the local time zone of the user. This function can be used in various scenarios, such as scheduling appointments, displaying dates and times in a particular time zone, and calculating the difference between two time zone values. By following the steps outlined in this article, you can easily use the TimeZoneOffset function in your Power Apps applications.

Power Apps Training Courses by G Com Solutions (0800 998 9248)