-
-
Save baseboxorg/e144474d83115e05d27d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
from dateutil import tz | |
from_zone = tz.tzutc() | |
to_zone = tz.tzlocal() | |
#Get a naive datetime | |
utc = datetime.utcnow() | |
#Represent it as UTC time | |
utc = utc.replace(tzinfo=from_zone) | |
#Convert to local timezone | |
local = utc.astimezone(to_zone) | |
print "UTC: ", utc | |
print "LOCAL: ", local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment