When creating custom web templates, that include time zone dependent date time fields coming from CRM, you might encounter some issues regarding time zones. In this example we will recreate this issue and give you an explanation on how to solve this.
To demonstrate the issue, include the following code snippet in one of your custom templates:
<div id="contactInfo"> Name: {{user.fullname}}</br> Birthday: {{user.birthdate}}</br> Last succesfull login: {{user.adx_identity_lastsuccessfullogin}}</br> </div>
When going to the portal we can see that our information is rendered on the form but that the data is not displayed correctly:
CRM |
![]() |
vs.
Portal |
![]() |
We can see that the portal isn’t taking the correct time zone automatically. To display the correct value, we need to slightly adapt our code snippet:
<div id="contactInfo"> Name: {{user.fullname}}</br> Birthday: {{user.birthdate}}</br> Birthday (v2): <time datetime="{{user.birthdate | date_to_iso8601}}"></time></br> Last succesfull login: {{user.adx_identity_lastsuccessfullogin}}</br> Last succesfull login (v2): <time datetime="{{user.adx_identity_lastsuccessfullogin | date_to_iso8601}}"></time></br> </div>
When rendering this on the portal we can see the correct values:
Portal |
![]() |
So the solution to the time zone problem is actually very simple and requires you to only change 1 line of code:
<time datetime="{{<<your field>> | date_to_iso8601}}"></time>
[…] https://www.thrives.be/crm-portals/displaying-time-zone-dependent-fields-on-dynamics-portals/ […]
[…] When displaying a date time field from CRM the portal will automatically render the field like shown in the pictures below (see the previous post to see how to handle time zone dependent fields): […]
[…] bericht Displaying time zone dependent fields on Dynamics Portals verscheen eerst op […]