Use the .astimezone()
method:
dt.astimezone(pytz.UTC)
Pergunta
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)
?
Solução
Use the .astimezone()
method:
dt.astimezone(pytz.UTC)