Handling dates with Date Time Zone in PowerApps can be tricky. So while handling the dates in PowerApps you should be aware of few Date Time Zone settings. In this blog we will be discussing the same.
Date Time Zone Property in PowerApps can be set through Date Picker control. Under PowerApps inside Date Picker control there are two options available for Date Time Zone – Local and UTC respectively. You can find the same in below screenshot:
Depending upon which option you select in Date Time Zone, the date and time returned by the control behave differently. So make sure that this value is set correctly to meet your business scenario.
When you are developing PowerApps you need to make sure whether to use Local or UTC Date Time Zone depending upon the connector you are dealing with.
The user should experience the same date in PowerApps as well as in the connector to which PowerApps is integrated with.
In this blog we will explore a simple setting to handle the date and time fields of Dynamics 365 CRM according to user time zone in PowerApps.
Let’s consider an example by creating sample PowerApps which will demonstrate how Local and UTC date pickers work:
1. Create a default Canvas app for Opportunity entity by using Dynamics 365 CRM. For know-how you can refer the blog here.
2. As you know Opportunity entity contains Estimated Close Date, lets create the opportunity record in CRM with below Estimated Closed Date set:
3. Now, while accessing the same opportunity through PowerApps, we came across different dates for the same opportunity as shown below:
4. In this scenario, the time zone of Dynamics 365 CRM instance on which we were working was set as Mountain Time as shown in below screenshot:
But the app was running on phone where time zone was set as Indian Standard Time.
To avoid such scenarios there is a simple Date Time Zone setting in PowerApps that can be used while creating/updating records in Dynamics 365 CRM through PowerApps.
5. In the next scenario, it was observed that the Date Time Zone in PowerApps was kept as UTC option which was converting the date in UTC format and hence the difference in date field.
6. We simply changed Date time zone setting to Local option and it worked. Change it to Local as shown in below screenshot:
7. In this case, if you observe Estimated Close Date reflected in PowerApps then you will see that it is exactly same as latest date value in CRM. You can see in our example that the same date has been set in the PowerApps:
With this simple setting in PowerApps user can handle date and time field effectively.