I have a variable with a timestamp which I need to convert to a human readable format. Here is an example:
- name: Extract timestamp from output
set_fact:
timestamp: "{{ output.json | json_query(snap_timestamp) }}"
vars:
snap_timestamp: "[*].{Timestamp: timestamp}"
Output I get is:
{
"msg": "timestamp is [{'Timestamp': 1662628573}]"
}
I then tried to convert it with these filters but it doesn't work
- name: Convert timestamp to a human readable format
set_fact:
snap_timestamp_converted: "{{ snap_timestamp[0] | to_json | '%Y-%m-%d %H:%M:%S' | strftime }}"
Any idea?
Thanks.