argo-workflowsargoproj

Formatting dates in Argo


In order to get a date like 20201008 in Argo, what's the best way of formatting a date in a template?

This seems to work but is fairly verbose, and creating the string for something like "%Y-%m-%dT%H:%M:%SZ" is going to get very difficult for others to read.

 "{{workflow.creationTimestamp.Y}}{{workflow.creationTimestamp.m}}{{workflow.creationTimestamp.d}}"

I think these are the relevant docs: https://github.com/argoproj/argo/blob/master/docs/variables.md. I tried "{{workflow.creationTimestamp.Ymd}}" but no luck.


Solution

  • Since Argo 3.1, some templating is supported, such that this now works:

    "{{=sprig.date('20060102', workflow.creationTimestamp)}}"