mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 08:16:53 +00:00
Add UNIX timestamp detection to the as_datetime template filter (#20394)
This commit is contained in:
parent
09bb6e8379
commit
777a78bf6e
@ -318,7 +318,7 @@ The same thing can also be expressed as a filter:
|
||||
|
||||
{% endraw %}
|
||||
|
||||
- `as_datetime()` converts a string containing a timestamp to a datetime object.
|
||||
- `as_datetime()` converts a string containing a timestamp, or valid UNIX timestamp, to a datetime object.
|
||||
- `as_timestamp(value, default)` converts datetime object or string to UNIX timestamp. If that fails, returns the `default` value, or if omitted `None`. This function also be used as a filter.
|
||||
- `as_local()` converts datetime object to local time. This function also be used as a filter.
|
||||
- `strptime(string, format)` parses a string based on a [format](https://docs.python.org/3.8/library/datetime.html#strftime-and-strptime-behavior) and returns a datetime object. If that fails, returns the `default` value, or if omitted the unprocessed input value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user