Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Converting time zone in Microsoft Power Automate


View products that this article applies to.

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.

↑ Back to the top


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. 

↑ Back to the top


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.

[Asset 4557834]

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

[Asset 4557835]

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.

[Asset 4557837]

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.

 

↑ Back to the top


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. 

[Asset 4557838]

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

 

 

↑ Back to the top


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.

↑ Back to the top


Keywords: datetime, power automate, time zone

↑ Back to the top

Article Info
Article ID : 4557244
Revision : 12
Created on : 4/17/2020
Published on : 4/17/2020
Exists online : False
Views : 143