Datetime templating

I have a sensor which gives me a datetime stamp which is always in the future.
The value looks like this:

2023-04-21T15:56:37+00:00

I have been looking at Templating - Home Assistant and I cannot work out how to convert that to some sort of usable value.
I need to subtract the current datetime from that value and obtain the amount of seconds but cannot work out the correct way to convert it to a valid datetime value that a template acceps.

{{ as_timestamp(states('sensor.your_sensor') - as_timestamp(now()) }}

Tried that already doesn’t work
image

Please show the output for {{ states('sensor.YOUR_SENSOR') }} pasted into the Developer Tools / Template Editor tool.

Ok it did work, the brackets were it the wrong place hence the error.
It gives me this value: 11850.948045015335
How to turn that to seconds?

That is in seconds.

1 Like

Awesome thanks for that :grinning: