Power Platform Tip #17

The time zone bug in your flow is the assumption, not the conversion

Find out which zone the datetime is already in before you convert it, then name that zone as the source: connectors differ, and the action converts from the zone you name.

The zone comes from the connector, not from your flow

A datetime arrives from a trigger or an action, and the zone it is in is the sender’s choice: connectors differ in the formats and zones they use, and some services work strictly in UTC to avoid confusion. A trailing Z is how a UTC value shows itself, the way 2020-04-10T01:28:14.0406387Z does in the guidance. When you are unsure what format the datetime is in, running the flow and reading what the action produced is what Microsoft points you at, and it answers the question the conversion depends on.

The action asks you to name the source zone

Convert time zone, the built-in operation, takes a base time, a source time zone, a destination time zone and an optional format string. The source time zone is the zone the datetime is currently in, which means the value you already have rather than the zone you want it to end up in. That input describes the raw value, so read it off the output the action printed instead of filling it in from memory.

The functions name the direction

When one end of a conversion is UTC, the function name carries the direction: convertFromUtc converts a UTC timestamp to a target zone, and convertToUtc converts a timestamp in a named zone to UTC. When both ends need writing out, convertTimeZone takes the source zone and the destination zone:

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

The zone names are the Windows ones, listed under Microsoft Windows Default Time Zones in the reference, and a name can need its punctuation removed before the function accepts it.

An ISO8601 message is about the value, not the zone

The error the guidance shows as its example is that the date time string must match ISO8601 format. That names the shape of the string you passed rather than the zone you picked, so compare the raw value’s format against what the function takes before you change anything about the conversion.

Some connectors show the zone their own way

Some connectors have limitations in how the time zone displays, and the connector reference is where each one’s behaviour is written down. The datetime an action hands you is that connector’s output, so the source zone you name belongs to the action you took the value from.