Created
February 1, 2011 00:03
-
-
Save saghul/805107 to your computer and use it in GitHub Desktop.
Example for creating timezone aware datetime objects with dateutil
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
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