1

I've used dateutil to convert the string 'Wed, 19 Dec 2012 01:34:52 -0800' to date time datetime.datetime(2012, 12, 19, 1, 34, 52, tzinfo=tzoffset(None, -28800)). How can I convert it to UTD+0 datetime.datetime(2012, 12, 19, 9, 34, 52) ?

1 Answer 1

3

Use the .astimezone() method:

dt.astimezone(pytz.UTC)
Sign up to request clarification or add additional context in comments.

2 Comments

@ShawnChin, you can also use the dateutil UTC implementation tzutc().
@ShawnChin: You can use any module that has a UTC representation. dateutil has one for you, as does iso8601.

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.