Bootstrap FreeKB - Ansible - Make a date human readable using the strftime filter
Ansible - Make a date human readable using the strftime filter

Updated:   |  Ansible articles

The strftime filter is used to convert a date format string into a human readable date. Or, the ansible_date_time is a magic can be used. Or, the lookup plugin can be used.

In this example, %Y-%m-%d is converted.

- name: "format date using the strftime filter"
  debug:
    msg: "{{ '%Y-%m-%d' | strftime }}"

 

Something like this should be returned.

TASK [format date using the strftime filter]
ok: [server1.example.com] => {
    "msg": [
        "2020-12-05"
    ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 7004ff in the box below so that we can be sure you are a human.