Hello,
I want to reformat a date and time in a markdown.
The Format of the attribute is:
2021-08-28T18:00:00+02:00
I want to reformat ist to:
DD.MM.YYYY HH:MM o clock
I am currently doing the edition like this:
{{ states.sensor.ical_adler_mannheim_event_0.attributes.summary }}
What do I have to change with this code so that I get the format I want
Have you tried the docs? I know working with dates and times can be confusing, but tell us what you’ve tried.
I have tried it with:
{{ states.sensor.ical_adler_mannheim_event_0.attributes | first | as_timestamp | timestamp_custom("%d.%m.%Y %H:%M")}}
But this display:
none and not the Date with time.
koying
(Chris B)
4
You forgot .summary
and | first
is superfluous.
As a reminder, you have a nice template test tool under “Developer tools”.
Ok, I Change the Code to:
{{ states.sensor.ical_adler_mannheim_event_0.attributes.start |
timestamp_custom("%d.%m.%Y %H:%M") }}
Because the attribute is start.
But the display now:
2021-08-19 17:30:00+02:00
I hav trie it also with the template test tool. But I don’t know what I must change now.
Now i got ist with:
{{ as_timestamp(states.sensor.ical_adler_mannheim_event_0.attributes.start) | timestamp_custom('%d.%m.%Y %H:%M Uhr') }}
Hard to say what’s going wrong without seeing what that raw sensor state looks like, but this works:
{% set t = "2021-08-28T18:00:00+02:00" %}
{{ t | as_timestamp | timestamp_custom("%d.%m.%Y %H:%M") }}
1 Like