1

If there was no (UTC), it would be: %a, %d %b %Y %X %z but server is sending with additional (UTC) or (CDT) how do you parse it? %a, %d %b %Y %X %z (%Z) doesn't work.

  • I hope you have stripped out the extra spaces, if any... – Mortz Jun 25 '21 at 14:17
  • Does this answer your question? [Convert timestamps with offset to datetime obj using strptime](https://stackoverflow.com/questions/12281975/convert-timestamps-with-offset-to-datetime-obj-using-strptime) – Chillie Jun 25 '21 at 14:23

1 Answers1

1

How does it not work? Which version of python are you using? I just ran the following in python 3.9:

datetime.datetime.strptime("Fri, 25 Jun 2021 12:06:16 +0000 (UTC)", "%a, %d %b %Y %X %z (%Z)")

Which created this datetime object:

datetime.datetime(2021, 6, 25, 12, 6, 16, tzinfo=datetime.timezone(datetime.timedelta(0), 'UTC'))
phil0x2e
  • 73
  • 5