Format dates in templates


Is there a way to format dates in templates?
In the frontend its possible to format with moment.js which works well.

But if i output a date in a html-template i get the following output:
2021-05-11 13:28:32 +0000 UTC

I tried to format the date with printf but if its possible my syntax is not right.

By now it seems i ll have to set a renderVar for every date in my workflow before i render the template. That seems to be a lot of extra work for this simple usecase. Especially if i want to output a formated standard field like createdAt.

How would I implement such a feature to the template engine? I had a quick look at github files but i m not a go dev and i m still struggling with the structure. May be someone is able to set up a “step by step” developer tutorial for such a feature implementation - or maybe a git commit for such a feature would be enough to get the point.

The renderer includes sprig template functions. The date function should do the trick for you.
We’ll expand on this documentation sometime before the next release.

Feel free to share any feedback/suggestion.

That helps a lot :wink:

{{ date "02.01.2006 15:04" .test.values.createdAt }}
or with Timezone
{{ dateInZone "02.01.2006 15:04" .test.values.createdAt "CET" }}