Removing Milliseconds

I have this template:

{{ now() - state_attr('automation.02_washingmachine_is_finished','last_triggered') }}

It shows Milliseconds, I would like that to be not shown, how can I do this?

Cheers

either via strftime or add brackets around the result and then

.replace(microsecond=0)
{{ ((now() - state_attr('automation.02_washingmachine_is_finished','last_triggered'))|string).split('.')[0] }}

Yeah…just noticed that replace does not work for a timedelta…any idea what the logic/idea is behind that?

You could do:

{% set dt = now() - state_attr('automation.02_washingmachine_is_finished','last_triggered') %}
{{ dt - timedelta(microseconds=dt.microseconds) }}

One more option:

{% set dt = now() - state_attr('automation.02_washingmachine_is_finished','last_triggered') %}
{{ timedelta(seconds=(td.total_seconds() | round(0))) }}

Edit: note that this will round to the nearest second unlike the other solutions this thread which will truncate. Not sure if it matters.

Thank you very much, this works asome.