8000 Update templating.markdown for `as_datetime` (#39498) · home-assistant/home-assistant.io@43db9e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43db9e6

Browse files
authored
Update templating.markdown for as_datetime (#39498)
1 parent 1126174 commit 43db9e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/_docs/configuration/templating.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ For example, if you wanted to select a field from `trigger` in an automation bas
774774

775775
{% endraw %}
776776

777-
- `as_datetime(value, default)` converts a string containing a timestamp, or valid UNIX timestamp, to a datetime object. If that fails, it returns the `default` value or, if omitted, raises an error. When the input is already a datetime object it will be returned as is. in case the input is a datetime.date object, midnight will be added as time. This function can also be used as a filter.
777+
- `as_datetime(value, default)` converts a string containing a timestamp or a valid UNIX timestamp to a datetime object. If conversion fails, the function returns the `default` value. If no `default` is provided and the input is a string that cannot be converted to a datetime, it returns `None`. For other invalid inputs (e.g., a list, dictionary, or a numeric value too large to convert), it raises an error when no `default` is supplied. In case the input is already a datetime object, it is returned unchanged. If the input is a `datetime.date` object, midnight is added as the time. This function can also be used as a filter.
778778
- `as_timestamp(value, default)` converts a datetime object or string to UNIX timestamp. If that fails, returns the `default` value, or if omitted raises an error. This function can also be used as a filter.
779779
- `as_local()` converts a datetime object to local time. This function can also be used as a filter.
780780
- `strptime(string, format, default)` parses a string based on a [format](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) and returns a datetime object. If that fails, it returns the `default` value or, if omitted, raises an error.

0 commit comments

Comments
 (0)
0