1

I know there are a lot of threads and stuff out there, but haven't been able to find a solution to my problem. It seems to be an issue with the timezone of the input value:

I'm trying the following:

set_fact:
  converted: "{{ ('20290422210804Z' | to_datetime('%Y%m%d%H%M%S%Z')) }}"

I've also tried %z as I've seen in some python-related threads mention the different case, but they both return the error:

time data '20290422210804Z' does not match format '%Y%m%d%H%M%S%Z'

If I remove the tailing 'Z' from the input and the %Z from the to_datetime function, it works fine. I only have a problem when I have the timezone identifier at the end.

I'm getting the input value from a file, so I don't have a whole lot of control over the input format, unless I take the extra step to parse out the timezone, which I prefer not to do.

Any suggestion?

JScott
  • 73
  • 2
  • 9
  • Does [time data does not match format](https://stackoverflow.com/questions/28408614/) answer your question? For an ISO formatted date the `T` is missing and you can't just strip the `Z`, see [How do I parse an ISO 8601 formatted date?](https://stackoverflow.com/questions/127803/). – U880D Sep 29 '21 at 06:57

0 Answers0