How to convert to only HH:SS

Hello People,

I am hitting a wall with converting the time format. i have a sensor: sensor.power_highest_peak_time_today

Which gives: 2022-10-23T11:00:00+00:00
I only need and want is the 11:00

I am new with python en coding in HA but this i tried but dit not work

{% set dt = states('sensor.power_highest_peak_time_today') %}
{% time = dt.strftime("%H:%M:%S") %}
{{ time }}

Please help

States are always strings… attributes can be other data types like floats, integers, arrays, or datetime objects, but states are always string. As such, you need to convert them to a datetime object before you can use strftime()

{% set dt = states('sensor.power_highest_peak_time_today') | as_datetime | as_local %}
{{ dt.strftime("%H:%M") }}

Thanx alot for the extra information that helps me alot!

It worked, now i can ask google when the peak solar time is!

You can slice the string like this:

{{ states('sensor.power_highest_peak_time_today')[-14:-9] }}