cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abrae005
Kudo Collector
Kudo Collector

Handling Time Zones

I'm trying to build an "Event Calendar" app for a global user base. The app is based on a SharePoint list.

 

Right now, I have 4 fields in my list for Date/Time:

  • Event Start Date - Date/Time format, with no Time
  • Event Start Time - Text
  • Event End Date - Date/Time format, with no Time
  • Event End Time - Text

Ideally, I'd like users to be able to enter events in their own time zone, and have it automatically display in the time zone of the user who is viewing it.

 

I can add additional columns to SP if it would make things easier. Within the app itself, there is filtering to display various icons based on "Is there an event on this date?"

Filter(
        'Event Calendar',
        'Event Start Date' <= DateAdd(_FirstDayInView, ThisItem.Value, Days),
        'Event End Date' >= DateAdd(_FirstDayInView, ThisItem.Value, Days)
    )

 

So, my questions are:

  1. Within the App, I'm creating an input form. What fields should I include, and is there code I need to add when saving to capture the time zone info of the user who is saving?
  2. On the Calendar View, how do I retrieve the time zone in the current user's local time, which may be different from the time zone that was originally saved?
1 ACCEPTED SOLUTION

Accepted Solutions

Found a solution!

 

Thanks to this post https://powerusers.microsoft.com/t5/Building-Power-Apps/Calendar-gallery-display-circles-for-each-da... by @v-xida-msft , I was able to change my filter, and it worked.

 

For those future users who find this post on a google search and wonder exactly what I did, here is the new .Visible code for my icon:

/* Visible if Calendar Events are found on this day */
CountRows(
    Filter(
        'System Health Dashboard',
        DateValue(Text(Start_DT_UTC)) <= DateAdd(_FirstDayInView, ThisItem.Value, Days), 
        ((DateValue(Text(End_DT_UTC)) >= DateAdd(_FirstDayInView, ThisItem.Value, Days)) || (IsBlank(End_DT_UTC)))
    )
) > 0

(Basically, the difference is now instead of just looking at Start_DT_UTC or End_DT_UTC, I'm looking at the DateValue of the Text of those.)

View solution in original post

10 REPLIES 10
v-yutliu-msft
Community Support
Community Support

Hi @abrae005 ,

Do you want to transfer time based on current user's time zone?

If so, I suggest you try TimeZoneOffset() function, which will return time interval between local time zone and UTZ.

Formula like this could convert current time to utc.

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

 

In your issue, I suggest you:
1)create a timezone field(number type)

use data like this to update:

-TimeZoneOffset()/60

This will  capture the time zone info of the user who is saving.

For example: 

My local time is 3:pm, utc is 7am.

Then by using this formula, my time zone is 8, which means that my local time is quicker 8 hours than utc.

 

2)you could compare current time zone with data in timezone field

For example:

current time zone:

-TimeZoneOffset()/60

 data in timezone field:

ThisItem.timezone

If current time zone is 2, data in timezone field is 8, then local time is slower 6 hours than timezone that this field was created.

You could use DateAdd to transfer between them.

 

 

I suggest you know more about these functions:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

Your advice seems to be working partially. I added a field to my SP List called TZ_Offset_Hours, and am using 

-TimeZoneOffset()/60

to populate that. It is correctly showing my time zone as UTC -4.

 

However, the form seems to be not converting correctly. I created an item with an End_DT_UTC of 9/3, 02:01 AM. That form field should be in UTC. When I look in SharePoint, it shows up as 9/2, 23:01. But, since my UTC offset is -4, it should be 22:01.

PA_Form.png

 

SP_List.png

 

Additionally, I want to, on my form, have users enter the time in their local time, and not need to convert that to UTC. I'm guessing I need to add new input fields for that, and then add logic to have that populate the "default" form fields with the conversion?

 

Lastly, my "Calendar View" is not filtering correctly. I set the "OnVisible" property of my warning icon to:

/*Visible if calendar events are found on this day*/
!IsEmpty(
    Filter(
        'System Health Dashboard',
        DateAdd(Start_DT_UTC, _UTCOffSet, Hours) <= DateAdd(_FirstDayInView, ThisItem.Value, Days),
        ((DateAdd(End_DT_UTC, _UTCOffSet, Hours) >= DateAdd(_FirstDayInView, ThisItem.Value, Days)) || (IsBlank(End_DT_UTC)))
    )
)

but the icon is still showing up starting on 8/31, even though that's the UTC start date, and local start date would be 8/30.

calendar_view.png

Hi @abrae005 ,

Please notice two things:

1)in powerapps, default time zone is local time zone.

2)in sharepoint list, its time zone is set by yourself.

So time in powerapps and in sharepoint maybe different.

 

To change a sharepoint list time zone, you should operate like this:
settings->site information->view all site sittings->regional settings

921.PNG

922.PNG

 

 The time zone you set in that will your sharepoint list time zone.

 

If you update time from powerapps to sharepoint list, system will convert time from local time zone to the time zone you set in sharepoint list automatically.

 

So I suggest you check:

1)local time zone in powerapps

2)time zone in sharepoint list

Then convert time based on your demands.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

Changing the time zone on the SharePoint site fixed the issue with the date showing incorrectly on the View/Edit form, and on the Details Popup. However, the calendar icons are still not showing correctly.

 

The "Visible" property on the Warning icon is:

/*Visible if calendar events are found on this day*/
!IsEmpty(
    Filter(
        'System Health Dashboard',
        Start_DT_UTC <= DateAdd(_FirstDayInView, ThisItem.Value, Days),
        ((End_DT_UTC >= DateAdd(_FirstDayInView, ThisItem.Value, Days)) || (IsBlank(End_DT_UTC)))
    )
)

I have an event that starts on 8/31 at 2:27 AM UTC, which is 8/30, 22:27 local time. The icon should show on 8/30, but it's only showing up starting 8/31. 

 

(If I click on the warning icon, it brings up the Details Popup, and that is showing correctly.

cal_view.png

Hi @abrae005 ,

Could you tell me:

1)formula in this gallery's Items

2)what does "_FirstDayInView" and  "ThisItem.Value" represent?

Please notice that:
if you want to convert local time to utc time, you should use formula like this:

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

If you want to convert utc to local time, you should use formula like this:

DateAdd( StartTime, −TimeZoneOffset( StartTime ), Minutes )

 I think your problem should be about converting time.

I suggest you read this doc in details to check how to converting time between utc and local time:

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

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft 

 

The Gallery Items formula isn't actually a formula, but a list of items. I am basically using the gallery to make the calendar layout. There are 42 items, because I have 6 rows (weeks) times 7 values (dates) per row.

[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]

 

_FirstDayInView is set on the Screen's OnVisible. There are several values that are set to populate the calendar, and have the date numbers appear in the calendar boxes:

Set(_DateSelected, _CurrentDate);
Set(_FirstDayofMonth, DateAdd(_DateSelected, 1 - Day(_DateSelected), Days));
Set(_FirstDayInView, DateAdd(_FirstDayofMonth, -(Weekday(_FirstDayofMonth) - 2 + 1), Days));
Set(_LastDayofMonth, DateAdd(DateAdd(_FirstDayofMonth, 1, Months), -1, Days));
Set(_MinDate, DateAdd(_FirstDayofMonth, -(Weekday(_FirstDayofMonth) - 2 + 1),Days));
Set(_MaxDate, DateAdd(DateAdd(_FirstDayofMonth, -(Weekday(_FirstDayofMonth) - 2 +1), Days), 41, Days))

 

ThisItem.Value represents the date on the particular calendar square. So, for example, if I am looking at the square for September 1, the ThisItem.Value would be 9/1/2020.

Hi @abrae005 ,

When compare time in powerapps, you need to convert utc time to local time.

In powerapps, time zone is local time zone, not utc.

So please set  "Visible" property on the Warning icon:

/*Visible if calendar events are found on this day*/
!IsEmpty(
    Filter(
        'System Health Dashboard',
        DateAdd(Start_DT_UTC, _UTCOffSet, Hours) <= DateAdd(_FirstDayInView, ThisItem.Value, Days),
        ((DateAdd(End_DT_UTC, _UTCOffSet, Hours) >= DateAdd(_FirstDayInView, ThisItem.Value, Days)) || (IsBlank(End_DT_UTC)))
    )
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

Thanks for your continued efforts trying to help me. Unfortunately, it's still not working. I added the DateAdd _UTCOffSet to the filter, and I'm still getting the same results.

 

In the screenshot I posted the other day, you can see that the Details Popup for that item is working correctly. And the "Text" for that label is below, no conversion for time zone. I just can't seem to figure out why it's displaying correctly (with no conversion) for a label, but it's not working (either with or without conversion) for the Icon filter.

"Outage Start: " & ThisItem.Start_DT_UTC

 

Found a solution!

 

Thanks to this post https://powerusers.microsoft.com/t5/Building-Power-Apps/Calendar-gallery-display-circles-for-each-da... by @v-xida-msft , I was able to change my filter, and it worked.

 

For those future users who find this post on a google search and wonder exactly what I did, here is the new .Visible code for my icon:

/* Visible if Calendar Events are found on this day */
CountRows(
    Filter(
        'System Health Dashboard',
        DateValue(Text(Start_DT_UTC)) <= DateAdd(_FirstDayInView, ThisItem.Value, Days), 
        ((DateValue(Text(End_DT_UTC)) >= DateAdd(_FirstDayInView, ThisItem.Value, Days)) || (IsBlank(End_DT_UTC)))
    )
) > 0

(Basically, the difference is now instead of just looking at Start_DT_UTC or End_DT_UTC, I'm looking at the DateValue of the Text of those.)

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (813)