Convert Unix timestamp to human-readable date using Liquid in APIM policy

Djordje Novakovic 626 Reputation points
2023-01-06T15:55:14.977+00:00

Hello,

I have timestamp value returned by Azure APIM policy using Liquid:

"date_last_beat": "1672157423"

and I would like to convert it to human-readable format using Liquid.

I tried something like this using "date" and "Date" but it does not work:

"date_last_beat" : "{{device.date_last_beat | date: %D}}"
"date_last_beat" : "{{device.date_last_beat | Date: %D}}"
"date_last_beat" : "{{device.date_last_beat | date: “%d/%m/%y”}}"

Is there something special when using it with Azure API Management?

Thanks

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,452 questions
0 comments No comments
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 29,266 Reputation points
    2023-01-07T05:24:58.7+00:00

    Hi @Djordje Novakovic Thanks for reaching out. Simple conversions like below works with liquid template however, for unix time (Epoch timestamp), it seems there is no way. The reason is that we use dotliquid nuget package and that package does not support this specific conversion

    277067-image.png

    Reference: https://github.com/dotliquid/dotliquid/issues/322

    Feel free to leave your feedback at aka.ms/apimwish so that other users who are in need to similar feature can upvote it and PG can take it forward.

    Do let me know if you have any further queries.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.