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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM Portals date issue - liquid rendering date in UTC

(0) ShareShare
ReportReport
Posted on by 480

Hi Everyone,

I am having an issue while retrieving a date field from CRM using Fetchxml and displaying it using web template in CRM Portals.

Date is CRM:

10/10/2018 00:00:00  (TimeZone UTC+10:00)

Liquid

{% assign PaidUntil=result['sa.cca_paiduntil'] | date: 'dd/MM/yyyy' %} 

{{PaidUntil}}  render the below:

09/10/2018

Actual value without formattting (retrieved in Portals)

{{result['sa.cca_paiduntil']}} 

09/10/2018 02:00:00 PM

Screenshot for more clarity below:

crmportalsdate.png

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Nicholas Hayduk Profile Picture
    2,863 on at

    Hi Rizwan,

    Because the behavior of the field is User Local, the date you get is in UTC time, which is the 09/10/2018 02:00:00 PM you mention.  If you want to display in the user's browser timezone, I'd recommend using either https://momentjs.com/ or http://timeago.yarp.com/, both of which are included as libraries in Portals already.

    You could also use liquid filters if you wanted to provide a hard-coded offset from UTC:

    {{ result['sa.cca_paiduntil'] | date_add_hours: 10 }}

    Nick

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Rizwan,

    Dynamics CRM basically converts the date as per your time zone when it's display. But actually it's save the datetime value in database by converting UTC. This is very confusing when you are accessing system with different timezone.The date will display as per your machine timezone.

    Now for your case if you don't need any datetime to save just make your field without time . You can change the field behavior by modifying the field.

    So just change the field behavior and select date only value.

  • Verified answer
    Rizwan Aarif Profile Picture
    480 on at

    Thanks Nicholas,

    I managed it using moment like below:-

    I assigned {{serverdatevalue}} to a hidden field and then..

    var date = moment(hdnpaiduntil).format("YYYY-MM-DD");  

    var theTime = moment(hdnpaiduntil).format("HH:mm:ss");

    var stamp = date + "T" + theTime + "Z";

    var momentTime = moment(stamp);

    var datetimeAU= new Date(momentTime).toLocaleString('en-AU',{timeZone:'Australia/Brisbane'});

    var dateAU = datetimeAU.split(',');

    and retrieved it using first element dateAU[0]

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans