Skip to content

Instantly share code, notes, and snippets.

@saghul
Created February 1, 2011 00:03
Show Gist options
  • Save saghul/805107 to your computer and use it in GitHub Desktop.
Save saghul/805107 to your computer and use it in GitHub Desktop.
Example for creating timezone aware datetime objects with dateutil
In [20]: from datetime import datetime
In [21]: from dateutil.tz import tzlocal
In [22]: now = datetime.now(tzlocal())
In [23]: timestamp = now.replace(microsecond=0).isoformat()
In [24]: print timestamp
-------> print(timestamp)
2011-02-01T01:05:00+01:00
In [25]: now.tzname()
Out[25]: 'CET'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment