Template: format last_changed with local time

How do I format the last_changed attribute of a state in local time? This code outputs the date as UTC:

{{ states.input_text.last_activity.last_changed.strftime('%H:%M %Y-%m-%d') }}
{{ states.input_text.last_activity.last_changed.timestamp() | timestamp_local }}

or

{{ as_timestamp(states.input_text.last_activity.last_changed) | timestamp_local }}
2 Likes

Thanks, works perfect!

I use the form

{{ states.input_text.last_activity.last_changed.timestamp() | timestamp_custom('%a, %b %d, %Y at %H:%M', true) }}

to get custom formatting.

2 Likes