Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Unanswered

get local date time in liquid

(0) ShareShare
ReportReport
Posted on by 66

hi,

 

How can i get local date time in liquid. When i am using below code, it is returning me utc date time.

 

{% assign currentDateTime= now %}
 
i want current date of user and set value in currentDateTime in liquid.

Thanks
  • oliver.rodrigues Profile Picture
    9,342 Most Valuable Professional on at
    Re: get local date time in liquid

    Thanks, I didn't understand your issue was timezone.

    Take a look at this thread: Web Template : Display date in specific timezone - Microsoft Dynamics CRM Forum Community Forum

    it's a bit old but still valid, basically there is another filter you can use via Liquid, or you can also use the moment.js library

  • jeffgreenrc Profile Picture
    66 on at
    Re: get local date time in liquid

    Thank you for your response.

     

    I have done how you shown above. The issue with above code is, "now" returns value in utc time. Whereas, I want to get current local datetime.

     

    I want to basically set currentDateTime variable in liquid to users local current datetime.


    Thanks

  • oliver.rodrigues Profile Picture
    9,342 Most Valuable Professional on at
    Re: get local date time in liquid

    Hi, you can create a variable in liquid and assign the current date, and then use that in your fetch:

    {% assign currentDate = now | date: "yyyyMMddHHmmss" %}
    {% assign conditionCache = ' <condition attribute="new_name" operator="ne" value="' | append: currentDate | append: '" />' %}

    You can also define the format using the | date filter

    This example I am creating a condition and then using in a fetch, as per below: 

    {% fetchxml myFetch %}
     <fetch>
     <entity name="new_entityname">
     <filter type="and">
     {{ conditionCache }}
     </filter>
     </entity>
     </fetch>
    {% endfetchxml %}

     

  • jeffgreenrc Profile Picture
    66 on at
    Re: get local date time in liquid

    Thank you for your responses.


    I am using currentDateTime in fetchxml to load records based on datetime filter.

     

    In my current fetchxml entity datetime=currentDateTime.

     

    Thanks

     

  • oliver.rodrigues Profile Picture
    9,342 Most Valuable Professional on at
    Re: get local date time in liquid

    Tell us a bit more about your scenario. You might be able to use entity form metadata if you just need to set current date to a field. You might be able to achieve via plugins/workflows, etc. 

  • Fubar Profile Picture
    8,010 Super User 2025 Season 1 on at
    Re: get local date time in liquid

    Also, if you provide some indication of why you need it in Liquid etc it may help people to provide possible workarounds etc.

  • timl Profile Picture
    35,193 Super User 2025 Season 1 on at
    Re: get local date time in liquid

    Hi @jeffgreenrc 

    From what I see, there doesn't seem an easy way to do this.

    In the post here, Nicholas Hayduk recommends the JavaScript library moment.js.

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/268880/crm-portals-date-issue---liquid-rendering-date-in-utc?pifragment-97030=1

    That is, you could use liquid to retrieve todays utc date/time (or whatever date/time you want to format), and use moment.js to convert it to the local value, clientside.

    https://himbap.com/blog/?p=3493

    Is that something that could work for you?

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35