The TimeZoneOffset function in PowerApps returns the difference in minutes between the user's local time and UTC (Coordinated Universal Time). This function is useful when you need to handle time zone differences, especially in applications used across different regions.
PowerApps – TimeZoneOffset() function Syntax
- DateTime: The date and time value for which you want to calculate the time zone offset. If omitted, the current date and time is used.
Notes:
- Consistent Date and Time Values: Ensure that the date and time values you are working with are consistently formatted and include time zone information if necessary.
- Daylight Saving Time: Be aware of daylight saving time changes and how they affect time zone offsets.
PowerApps – Get difference between UTC and local time
To get the current time zone offset in minutes for the user's local time:
This returns the difference in minutes between the local time and UTC. For example, if the local time is UTC+2, this function returns -120 (since UTC is 120 minutes behind the local time).
PowerApps – GetTime zone offset of Specific Date and Time
To get the time zone offset for a specific date and time:
TimeZoneOffset(DateValue("2024-05-21T14:30:00Z"))
This returns the offset in minutes for the specified date and time value.
PowerApps – Convert Local Time to UTC
Suppose you have a local date and time value and you want to convert it to UTC:
DateAdd(LocalDateTime, TimeZoneOffset(LocalDateTime), Minutes)
This adjusts the local date and time to UTC by adding the time zone offset in minutes.
PowerApps – Adjust Time Zone Differences in Data
If you have a dataset with date and time values stored in UTC and you want to display them in the user's local time:
DateAdd(UTCDateTime, -TimeZoneOffset(UTCDateTime), Minutes)
This converts the UTC date and time to the local time by subtracting the time zone offset.
PowerApps – Handle Daylight Saving Time
The TimeZoneOffset function accounts for daylight saving time changes automatically. For example, during daylight saving time, the offset may change, and this function will reflect the correct offset:
TimeZoneOffset(DateValue("2024-07-01T12:00:00Z"))
This returns the offset in minutes during daylight saving time.