Help with time calculation

Please help.

I have a sensor with time attributes

{{states.sensor.price.attributes["item1"][0]["prices"][1]["postedTime"]}}

which returns time when the price posted in this format (2019-10-03T03:27:57.468Z)

How can I calculate time_since “postedTime” was posted?

time_since = (now) - (postedTime)

It’s been “time_since” price was posted

thanks

{{as_timestamp(now()) - as_timestamp(states.sensor.price.attributes["item1"][0]["prices"][1]["postedTime"])}}

will calculate the number of seconds since postedTime.

Thank you very much. Worked

1 Like