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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set the midnight time ...
Power Apps
Unanswered

Set the midnight time as per the user timezone

(0) ShareShare
ReportReport
Posted on by 220

Hi, I am capturing the midnight time from my server(which is my D365 instance) to display in the app. There is a custom logic written on my d365 end which stops a timer function exactly at midnight based on the server time (GMT).  I am in India Timezone, so the timer stops exactly at 5:29:59(server time) which is 23:59:59(India time).  Now since this is a global app, I would like to stop the time based on user's locale midnight time.  Is there a way to find  the user timezone and then stop the timer exactly at his midnight and not server midnight time.  

Below Function displays the Start and end time. 

 

If(ThisItem.Running = 0, Text(ThisItem.StartDateTime, "[$-en-US]mmm dd yyyy hh:mm:ss") & " - " & Text(ThisItem.EndDateTime, "[$-en-US]mmm dd yyyy hh:mm:ss"),
 Text(ThisItem.StartDateTime, "[$-en-US]mmm dd yyyy hh:mm:ss") & " - " & "Running")

 

 

In the attached image, it shows that the timer started at 20:06:18 and stopped at 05:29:59 [Time is in India timezone].

What I would like to see is the end time as midnight time as per user timezone. 


timerimage.png

Thanks in advance

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @P_SA ,

    You need the TimeZoneOffset function, which returns the user's difference to UTC.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • P_SA Profile Picture
    220 on at
    Hi, could you help me with the function. I am not sure how the offset works
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Thanks @P_SA ,

    Firstly, the TimeZoneOffset() returns the number of minutes the user's time zone is behind UTC as a positive value (a bit counter-intuitive when you first see it). My example (in Australian Eastern Time) for TimeZoneOffset(Now()) is -600, meaning I am 10 hours ahead of UTC. So you simply need to end the timer (say in India) 330 minutes (5.5 hours) before midnight or 6:30PM. The 330 will be -330 if someone in India used TimeZoneOffset(Now()) so the function will give you this value.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @P_SA ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • v-xida-msft Profile Picture
    on at

    Hi @P_SA ,

    Based on the needs that you mentioned, I think the TimeZoneOffset() function could achieve your needs. The TimeZoneOffset function is used to the number of minutes between the user's local time and UTC (Coordinated Universal Time).

     

    TimeZoneOffset() value = UTC (Coordinated Universal Time) - User's Local Time value

     

     

    On my side, the TimeZoneOffset function result returns -480 (negative value), it means I am is (UTC + 8 ) Time Zone. If the TimeZoneOffset() function result is 480 (positive value), it means it is in (UTC - 8 )Time Zone.

     

    If you want to convert your local time value into a UTC Time value, I think the combination of DateAdd function and TimeZoneOffset function could achieve your needs. Please take a try with the following workaround:

     

    DateAdd(Now(), TimeZoneOffset(), Minutes)

     

    On your side, you may need to type the following formula:

     

    If(
     ThisItem.Running = 0, 
     Text(
     DateAdd(ThisItem.StartDateTime, TimeZoneOffset(), Minutes), "[$-en-US]mmm dd yyyy hh:mm:ss") & " - " & Text(ThisItem.EndDateTime, "[$-en-US]mmm dd yyyy hh:mm:ss"
     ),
     Text(ThisItem.StartDateTime, "[$-en-US]mmm dd yyyy hh:mm:ss") & " - " & "Running"
    )

     

    Please check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

    If you want to convert UTC time value to local Time value, please modify above formula as below:

     

    DateAdd(Now(), -TimeZoneOffset(), Minutes)

     

     

    Best regards,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard