Last active
September 27, 2015 00:08
-
-
Save neoneo40/ef29ddcede07bcb20122 to your computer and use it in GitHub Desktop.
time.time() to strftime in python. %I, %p, %H. http://strftime.org/
This file contains hidden or 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
time.time() | |
# 1443311925.874013 | |
datetime.datetime.fromtimestamp(int(time.time())) | |
# datetime.datetime(2015, 9, 27, 8, 58, 40) | |
datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S') | |
# '2015-09-27 08:58:57' | |
datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %I:%M:%S %p') | |
# '2015-09-27 08:59:59 AM' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
References