hi,
How can i get local date time in liquid. When i am using below code, it is returning me utc date time.
Thanks
Announcements
hi,
How can i get local date time in liquid. When i am using below code, it is returning me utc date time.
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
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
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 %}
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
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.
Also, if you provide some indication of why you need it in Liquid etc it may help people to provide possible workarounds etc.
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.
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?
Lucas001
60
Super User 2025 Season 1
Fubar
55
Super User 2025 Season 1
surya narayanan
35