When customizing your Dynamics Portal you might want to change the format of datetime and date only fields. Unfortunately, formatting DateTime fields in Dynamics Portals is trickier than it sounds.
To demonstrate this, include the following code snippet in one of your custom templates or page copy, if this is displayed on your page:
<div id="contactInfo"> Name: {{user.fullname}}</br> Birthday: <time datetime="{{user.birthdate | date_to_iso8601}}"></time></br> Last succesfull login: <time datetime="{{user.adx_identity_lastsuccessfullogin | date_to_iso8601}}"></time> </div>
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):
If we want to customize the date time formatting we can create/adapt 2 site setting in or portal:
- DateTime/DateTimeFormat
- In our case we want: dd/MM/yyyy HH:mm
- DateTime/DateFormat
- In our case we want: dd/MM/yyyy
These settings will render the values in the portal, like the picture below:
If you only want to show the date of field, we can add the “date-only”-class to the time tag; like so:
Birthday: <time class="date-only" datetime="{{user.birthdate | date_to_iso8601}}"></time></br>
And voila, behold the magic:
!Warning: When you use a Date only field in an entity list, the portal will always take the DateTime format and not the DateFormat format.
i tried this but not changing date format in portal. any alternative method please.....
[…] bericht Formatting DateTime fields in Dynamics Portals verscheen eerst op […]