web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Get current logged in ...
Power Apps
Unanswered

Get current logged in user's time zone

(0) ShareShare
ReportReport
Posted on by 63

In our app we are creating MS Teams meetings using Teams Connector and Time zone is a required parameter. So I have created a Combobox and listed time zones from here.

 

Usmannb_2-1622719529168.png

 

Now I want to show logged in user's time zone as default selected tome zone in Combobox. Is it possible and if it is then how can i achieve this?

 

 

Categories:
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at
  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    That will calculate how many hours you are different from UTC, but since there are multiple time zones with the same offset it won't actually give you the time zone.  If you use the following code you can retrieve the user's City from their profile and use that to lookup the time zone. You will have to create an Excel spreadsheet or SharePoint list to use for the lookup.

    Office365Users.UserProfileV2(User().Email).city
  • Usmannb Profile Picture
    63 on at

    Hi @Pstork1 
    Thanks for the suggestion but it will be very difficult to create a list of all the cities in the world. Because our clients have offices all over the world.

     

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Unfortunately, then there is no way to retrieve the user's time zone other than asking them.  A user's time zone is not automatically set, they default to whatever is in their local browser or the SharePoint server location.  As @zmansuri mentioned, there is a way to get the timezoneoffset for the current user.  But that doesn't translate to the actual time zone without more information.  For example I am located in the US Central Time zone which is UTC -6.  But there are 4 other time zones also at UTC -6. So knowing it is UTC -6 doesn't actually tell me the time zone unless I also know its in the US.  The others are in Central America, Canada, Mexico, and Easter Island.

  • Usmannb Profile Picture
    63 on at

    Thanks @Pstork1 

     

  • MengtingXie Profile Picture
    112 on at

    I found a possible good way now for this after two years. Now it is possible to retrieve data through Graph API in the PowerApps. And it's super cool!

     

    First, you can test the Graph API query below to fetch current user time zone in the Graph Explorer:

     

    https://graph.microsoft.com/v1.0/me/mailboxSettings/timeZone

     

     

    Example as below, Get method. The version can be v0.1 or beta. I tested both version works.

     

    Before you run the query, please make sure to modify the permission under "Modify permissions" tab, consent to MailboxSettings.Read and MailboxSettings.ReadWrite permission.

     

    After runing the query, you can find the value in the response is the Timezone name.

     

    MengtingXie_5-1700650816624.png

     

    Second, you can create a blank PowerApps to test the Graph API.

    In the app, add the "Office365Group" data connection.

    MengtingXie_1-1700650478190.png

     

    Open moniter for the app, you will see the moniter does not have any log yet. 

    MengtingXie_2-1700650502629.png

    MengtingXie_3-1700650525136.png

     

    Back to the app editing page, insert a Button control and copy paste the below code to the "OnSelect" property of the button. Here

     

    Set(varCurrrentUserTimezone,Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/me/mailboxSettings/timeZone","GET",""))

     

    MengtingXie_4-1700650642751.png

     

    The varCurrrentUserTimezone is a UntypedObject that stored the response from the Graph API call.

    MengtingXie_6-1700650897014.png

     

    Click on the button, then navigate to the moniter tab in the browser. You will see a HttpRequest Operation has been recorded. Click on Office365Group in Data source column -> click on Response. You will see the response body gives you the exact data that you get in Graph Explorer. 

     

    MengtingXie_7-1700651082267.png

    Just add a label below the button, with the below code, you will see the time zone name. We use ".value" here because it is where the time zone is stored.

     

    varCurrrentUserTimezone.value

     

     

    MengtingXie_8-1700651346681.png

    If you want, you can get the UTC time of the time zone by using the below code:

     

    "(UTC"
     & If(TimeZoneOffset() > 0, "-",TimeZoneOffset() < 0, "+","")
     & Text(RoundDown(Abs(TimeZoneOffset()) / 60, 0),"00")
     & ":"
     & If(Mod(Abs(TimeZoneOffset()), 60) < 10, "0", "")
     & Mod(Abs(TimeZoneOffset()), 60)
     &")"

     

     

    MengtingXie_9-1700651550518.png

     

    Myself has created a SharePoint list based on the window defualt time zone.

    By useing the Lookup() for the Timezone list, I fetch the "Timezone desciprtion" (cities name).

     

    LookUp(Timezone,Timezone=Label1.Text).'Timezone description'

     

     

    MengtingXie_10-1700651737081.png

     

     

    I got inspired by Raze's cool video here Supercharge Your Power Apps with Direct Graph API Integration feel free to check this video. 

  • Usman2 Profile Picture
    124 on at

    Hi @MengtingXie 

    Thanks for the solution.
    There is just one issue that the "HttpRequest" is deprecated and the new "HttpRequestV2" only supports one segment which is  /groups.
    As I am trying to build a long term solution I do not want to use deprecated actions in my solution. What is your suggestion to achieve the same functionality as you described in your solution earlier, without using "HttpRequest" action.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard