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
Use the .astimezone() method:
dt.astimezone(pytz.UTC)
2 Comments
Mark Ransom
@ShawnChin, you can also use the
dateutil UTC implementation tzutc().Martijn Pieters
@ShawnChin: You can use any module that has a UTC representation.
dateutil has one for you, as does iso8601.