From bb642159c12fc0b6d82f08a8a36c34cb2d8b4f7b Mon Sep 17 00:00:00 2001 From: akasma74 Date: Sun, 20 Oct 2019 12:29:07 +0100 Subject: [PATCH] time: relative_time function - description added (#10847) It seems like the function itself has been there for a while but no mention of it in HA docs. --- source/_docs/configuration/templating.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index 6f130540c94..9719eb1c148 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -175,6 +175,7 @@ The same thing can also be expressed as a filter: - For specific values: `utcnow().second`, `utcnow().minute`, `utcnow().hour`, `utcnow().day`, `utcnow().month`, `utcnow().year`, `utcnow().weekday()` and `utcnow().isoweekday()`. - `as_timestamp()` will convert datetime object or string to UNIX timestamp. This function also be used as a filter. - `strptime(string, format)` will parse a string to a datetime based on a [format](https://docs.python.org/3.6/library/datetime.html#strftime-and-strptime-behavior). +- `relative_time` will convert datetime object to its human-friendly "age" string. The age can be in second, minute, hour, day, month or year (but only the biggest unit is considered, e.g. if it's 2 days and 3 hours, "2 days" will be returned). Note that it only works for dates _in the past_. - Filter `timestamp_local` will convert an UNIX timestamp to local time/data. - Filter `timestamp_utc` will convert a UNIX timestamp to UTC time/data. - Filter `timestamp_custom(format_string, local_boolean)` will convert a UNIX timestamp to a custom format, the use of a local timestamp is default. Supports the standard [Python time formatting options](https://docs.python.org/3/library/time.html#time.strftime).