|
|
@ -1184,6 +1184,25 @@ To get date object from string use the `to_datetime` filter, (new in version in
|
|
|
|
# get amount of days between two dates. This returns only number of days and discards remaining hours, minutes, and seconds
|
|
|
|
# get amount of days between two dates. This returns only number of days and discards remaining hours, minutes, and seconds
|
|
|
|
{{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).days }}
|
|
|
|
{{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).days }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To format a date using a string (like with the shell date command), use the "strftime" filter::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Display year-month-day
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Display hour:min:sec
|
|
|
|
|
|
|
|
{{ '%H:%M:%S' | strftime }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use ansible_date_time.epoch fact
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d %H:%M:%S' | strftime(ansible_date_time.epoch) }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use arbitrary epoch value
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime(0) }} # => 1970-01-01
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime(1441357287) }} # => 2015-09-04
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. note:: To get all string possibilities, check https://docs.python.org/2/library/time.html#time.strftime
|
|
|
|
|
|
|
|
|
|
|
|
Combination Filters
|
|
|
|
Combination Filters
|
|
|
|
````````````````````
|
|
|
|
````````````````````
|
|
|
|
|
|
|
|
|
|
|
@ -1209,25 +1228,6 @@ Combinations always require a set size::
|
|
|
|
|
|
|
|
|
|
|
|
Also see the :ref:`zip_filter`
|
|
|
|
Also see the :ref:`zip_filter`
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To format a date using a string (like with the shell date command), use the "strftime" filter::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Display year-month-day
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Display hour:min:sec
|
|
|
|
|
|
|
|
{{ '%H:%M:%S' | strftime }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use ansible_date_time.epoch fact
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d %H:%M:%S' | strftime(ansible_date_time.epoch) }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use arbitrary epoch value
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime(0) }} # => 1970-01-01
|
|
|
|
|
|
|
|
{{ '%Y-%m-%d' | strftime(1441357287) }} # => 2015-09-04
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. note:: To get all string possibilities, check https://docs.python.org/2/library/time.html#time.strftime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debugging Filters
|
|
|
|
Debugging Filters
|
|
|
|
`````````````````
|
|
|
|
`````````````````
|
|
|
|
|
|
|
|
|
|
|
|