I receive a Json in my yml file and then it goes to my jinja2 html file.
I can use my data whithout modification but when I try filters or whatever to format my date it's failed.
Like this it's work whithout formating the date:
<p>{{rule.occurences[0]}}</p>
result :
2021-01-28T09:40:10.970Z
I want it to be like this:
2021-01-28
I tried this to format my date :
<p>{{rule.occurences[0].strftime('%Y-%m-%d')}}</p>
result :
ERROR -- [TaskProcess] 'str object' has no attribute 'strftime'
I also tried a custom filter:
<p>{{rule.occurences[0]|datetimeformat('%d-%m-%Y')}}</p>
result :
ERROR -- [TaskProcess] datetimeformat() takes 1 positional argument but 2 were given
And also tried this one :
<p>{{rule.occurences[0]|iso8601_to_time|datetimeformat('%d-%m-%Y')}}</p>
result :
ERROR -- [load_file] Couldn't load file jinja2: no filter named 'iso8601_to_time'
Any idea to solve this please ?
question from:
https://stackoverflow.com/questions/65942813/how-to-format-a-jinja2-date-of-type-string 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…