Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Forked from dmdavis/utc_to_local.py
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanbehan/dd9d4ebd56ce8266f9d6 to your computer and use it in GitHub Desktop.
Save seanbehan/dd9d4ebd56ce8266f9d6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
"""
utc_to_local.py
Example of converting UTC to local time using python-dateutil.
https://pypi.python.org/pypi/python-dateutil
"""
from datetime import datetime
from dateutil.tz import tzutc, tzlocal
utc = datetime.now(tzutc())
print('UTC: ' + str(utc))
local = utc.astimezone(tzlocal())
print('Local: ' + str(local))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment