Time attribute - format to UTC?

Having a template sensor with an last_update atribute getting the time from {{ now() }}, its displayed like:

2020-04-29 19:03:56.035485+02:00 (without a T).

Looking at other timestamps for other (non template sensors) the time format is with a “T” like:

2020-04-29T04:26:03+02:00

How do I get my template time attribute to use the “T”-format?

Looking at the time section of the template docs, you probably need to use the timestamp_custom filter. But that also means reading up on the strftime docs to build the format you’re expecting.

That is the default display format for a Python datetime object, which is what now() returns. If you would prefer an ISO formatted string representing the value of the datetime object, try:

{{ now().isoformat() }}
1 Like