Created
August 20, 2013 12:07
-
-
Save wzpan/6280559 to your computer and use it in GitHub Desktop.
Python - timestamp
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
import datetime | |
# 2012-12-15 10:14:51.898000 | |
print datetime.datetime.utcnow() | |
# The now differs from utcnow as expected | |
# otherwise they work the same way: | |
# 2012-12-15 11:15:09.205000 | |
print datetime.datetime.now() | |
# You can render the timestamp to the ISO format string explicitly: | |
# '2012-12-15 11:15:24.984000' | |
str(datetime.datetime.now()) | |
# Or you can be even more explicit to format the | |
# timestamp the way you like: | |
# 'Saturday, 15. December 2012 11:19AM' | |
datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p") | |
# '2012-12-15' | |
datetime.datetime.now().strftime("%Y-%m-%d") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment