Use only hours and minutes from input_datetime

How can I only return hours and minutes from that state:


{{ state_attr('input_datetime.wecker', 'hour') }}
{{ state_attr('input_datetime.wecker', 'minute') }}

it depends on what the contents of that datetime entity is.

does it contain a date or only a time?

it also depends on what format you want it in.

do you want two numbers that represent just the hour and then just the minutes (19, 45)?

if so the datetime should have attributes for those two values you can use:

{{state_attr('input_datetime.wecker', 'hour')}}
{{state_attr('input_datetime.wecker', 'minute')}}

or do you want it in time format just without the seconds (19:45)?

if it contains a date then you should use a template like this:

{{states('input_datetime.wecker').split(' ')[1][:-3]}}

if no date then:

1 Like


This works. state_attr delivers 6:5 instead of 06:05.


1 Like