Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is DotLiquid or Azure Logic Apps automatically converting my date field?

I have a liquid template that includes a date field, which I am not using any filters on at all, but it's getting converted from 2020-04-11T22:02:11Z UTC to 4/11/2020 10:02:11 PM. Is this expected behavior of DotLiquid or Azure Logic Apps? How can I prevent it from doing this?

like image 918
Joey Eng Avatar asked Sep 02 '25 09:09

Joey Eng


1 Answers

I met the same problem in the past, liquid will convert the date time from 2020-04-11T22:02:11Z to 4/11/2020 10:02:11 PM automatically even if it is a string. As a workaround, we can use date format to convert it to the original date time.

For example, I have a json as below:

{
    "datetime": "2020-04-11T22:02:11Z"
}

We can use the liquid map like this:

{
    "datetime":"{{content.datetime | Date: "yyyy-MM-ddTHH:mm:ssZ"}}"
}

After that, we can get the original date format as 2020-04-11T22:02:11Z.

Hope it helps~

like image 75
Hury Shen Avatar answered Sep 05 '25 01:09

Hury Shen