Hi!
I have a date that I get from some source (I cannot change the source data), that looks like this: “Tue, 07 Apr 2020 08:16:10 +0000”. So I need to convert it to another datetime format.
The approach I took was I attempted to make it to datetime, but it doesn’t seem possible.
"{{ item.last_report_time | to_datetime('%a, %d %b %Y %H:%M:%S +%z') | default(omit) }}"
If I do this I get the error:
and could not be converted to an dict.The error was: ‘z’ is a bad directive in format ‘%a, %d %b %Y %H:%M:%S +%z’
If I omit the z i get the following error:
to_datetime(‘%a, %d %b %Y %H:%M:%S’) }}"}), and could not be converted to an dict.The error was: unconverted data remains: +0000
i’m also looping the results I get from an earlier step, so I am a bit hindered in my possibility of running a block of code to change the datetime. As far as I understand it, it needs to be done within the loop itself.
body_dict: agentVersion: "{{ item.agent_version }}" agentType: "{{ item.agent_type }}" lastReportTime: "{{ item.last_report_time | to_datetime('%a, %d %b %Y %H:%M:%S +%z') | default(omit) }}" with_items: "{{ result.output }}"
Any ideas?
Best regards,
Tony