0

I was looking at this reference but couldn't find how to handle the timezone offset (e.g. +0200) when parsing a string into date in Python.

My date string example is Thu Apr 17 10:50:39 2014 +0200.

If it were just Thu Apr 17 10:50:39 2014, the pattern %a %b %d %H:%M:%S %Y when using datetime.strptime.

Can I and how do I represent the offset in the date parse pattern?

1 Answer 1

1

There is no offset-template in the strptime-function, afaik. You could use dateutils for this one:

from dateutil.parser import parse
d=parse("Thu Apr 17 10:50:39 2014 +0200")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.