Converting time zone in Microsoft Power Automate

Applies to: Power Automate

Symptoms


When you are passing datetimes through triggers and actions in Microsoft Power Automate, users may find a datetime in the wrong time zone. Users may wish to convert the time zone (frequently in UTC) to their local time.

Cause


This is due to services passing dates through in varying formats or time zones. Each connector may use a different datetime format or time zone.

Some services use strictly UTC time to avoid confusion. 

Resolution


There are two ways to solve this - via an action or an expression. 

Using the action

Power Automate has a built-in operation called "Convert time zone".

Search for "convert time zone" and choose the "Convert time zone" operation.

Convert time zone action search in Power Automate

The "Convert time zone" operation has a few required inputs: 

Convert time zone action in Power Automate

Base time: The datetime you wish to convert.
Source time zone: The time zone that the datetime is currently in. 
Destination time zone: The time zone you want to convert your date to. 

See the "Notes" below for ways to find the current time zone.

 

Using the expression

Power Automate has an expression function for converting time zone.

Convert time zone expression in Power Automate

convertTimeZone(timestamp: string, sourceTimeZone: string, destinationTimeZone: string, format?: string)
Required. A string that contains the time.
Converts a string timestamp passed in from a source time zone to a target time zone

You will need to pass in the following: 

timestamp: The datetime you wish to convert. 
sourceTimeZone: The time zone the datetime is currently in.
destinationTimeZone: The time zone you want to convert your date to.
format (optional): The format of the time zone you wish to convert your date to. 

For example: 

convertTimeZone(triggerBody()?['Date'],'UTC','Eastern Standard Time','HH:mm')

Here, timestamp is "triggerBody()?['Date']", the source time zone is "UTC", the destination time zone is "Eastern Standard Time", and the format is "HH:mm".

Please see the convertTimeZone documentation for more information about this expression function.

 

Notes


Deciphering a datetime

Datetimes may come in different formats.

If your datetime has a "Z" at the end, it means it is in UTC time. For example: 2020-04-10T01:28:14.0406387Z

Please see Standard date and time format strings for more information about datetime formats.

You may get errors where your date time string is not in the correct format, ex. "The date time string must match ISO8601 format". Please see the formatDateTime expression documentation on how to correctly format your datetime string.

 

 

Checking the time zone of an output

If you are unsure what the datetime time zone is currently in, you can run your flow to take a look out the datetime output format. 

In this example, the "Get forecast for today" operation outputs the timestamp for when we got the forecast. 

Convert time zone example in Power Automate

This datetime is using the ISO-8601 datetime format. We can see that this operation outputs the datetime in the UTC timezone.

 

 

Limitations


There may be limitations in some connectors on how the time zone is displayed. Please see the connectors reference documentation for more details on each connector.