Did you know that Power Automate has a Date Time action that can easily convert, and format time zones in one action?
Why is this important? Power Automate natively uses UTC as its time zone, as well as most SharePoint sites. Using an action can be easier than using expressions.
In this example, we will want to get the current time (this will be in UTC since we will be using Power Automate) and converting the time to local time with a specific format.
First we want to get the current time, we can use the expression utcNow() but I will be showing how to use the Date Time actions instead.
The actions are under Date Time:
Add a Current time action, this action is the same as using utcNow() expression
Next add Convert time zone action, this action is very useful as it has pre loaded time zones and formats to choose from.
The inputs for this action are:
Base time: Use the output from the Current time action
Source time zone: Make sure to select Coordinated Universal Time
Destination time zone: Select your local time zone or the time zone you want
Format string: This dropdown has many ISO formats to choose from. If you want to have a custom format, simply click the drop down and select Enter custom value. See below for examples
If for some reason the format you want is not in the dropdown for formats, you can create a custom format as long as it follows ISO 8601 format. To add a custom format click Enter custom value in the dropdown
Some tips when creating a format for the date ‘2020-10-13‘ (October 13 2020)
yy = 20
yyyy = 2020
MM = 10
MMM = Oct
MMMM = October
dd = 13
ddd = Tue
dddd = Tuesday
yyyy-MMM-ddd = 2020-Oct-Tue
yy/MMMM/dddd = 20/October/Tuesday
dddd, MMMM, yyyy = Tuesday, October, 2020
MMMM dd, yyyy = October 13, 2020
yyyy-MM-dd = 2020-10-13 (used for comparing dates)
To add time to your format use the following in your format:
(It is best practice to add the letter ‘T’ before using time formats)
h = hours (12 hour time)
hh = hours (12 hour time)
HH = hours (24 hour time)
mm = minutes
ss = seconds
tt = Appends either AM or PM to time
Some examples are:
MMMM dd, yyyyThh:mm = October 13, 2020T12:51
MMMM/dd/yyyyTHH:mm:ss = October/13/2020T13:02:41
hh:mm:ss tt = 01:06:41 PM
h:mm:ss tt = 12:06:41 PM
Knowing these formats and the what each letter code does, the possibilities are endless. You can create any type of custom date time format easily.
As always if you have any questions, don’t hesitate to reach out.
Thank you for reading!
2 thoughts on “Converting Time Zones Easily In Power Automate”
Very nice blog Josh! Well done! You might want to use a utcNow() expression instead of a separate action if you want to save API Requests (especially handy when you are in a loop).
LikeLiked by 1 person
Thank you Daniel! You make a great point about saving API requests.