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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / get local date time in...
Power Pages
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
Categories:
I have the same question (0)
  • timl Profile Picture
    36,774 Super User 2026 Season 1 on at

    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?

  • Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

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

  • oliver.rodrigues Profile Picture
    9,449 Most Valuable Professional on at

    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. 

  • jeffgreenrc Profile Picture
    66 on at

    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,449 Most Valuable Professional on at

    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

    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,449 Most Valuable Professional on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
DP_Prabh Profile Picture

DP_Prabh 51

#2
rezarizvii Profile Picture

rezarizvii 35

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 35 Most Valuable Professional

Last 30 days Overall leaderboard