Frage

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) ?

War es hilfreich?

Lösung

Use the .astimezone() method:

dt.astimezone(pytz.UTC)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top