#Recreate default cosmetic formatting for timestamps

1 messages · Page 1 of 1 (latest)

faint bobcat
#

I find myself again asking what seems to be a question that surely must have been answered a thousand times before, but I just can't find it put simply anywhere.

In plenty of places within HA when you display a timestamp entity, it will nicely format it relatively for you like this - see image.

Problem is there is times when this doesn't happen, so how would I explicitly recreate this exact formatting using a template that represents it as a pre-made string?

I've tried time_since and relative_time but I'm clearly doing it wrong because they don't seem to do anything.

quasi lintel
#

If it’s not formatting it, you’re providing wrong info to the func

faint bobcat
#

What am I missing?

quasi lintel
#

Needs to be a timestamp or datetime object

#

You’re feeding it a string

faint bobcat
#

How do I not do that

#

The entity is a timestamp

quasi lintel
#

All states are strings

faint bobcat
#

This good to know

quasi lintel
#

Use as_datetime

faint bobcat
#

Ahhh awesome thanks, I had tried as_timestamp earlier not as_datetime

quasi lintel
#

It won’t be like the relative time in the frontend