Created
January 25, 2019 18:09
-
-
Save scienceystuff/48e07005a2021b930b2852d8ecd26651 to your computer and use it in GitHub Desktop.
timestamp in python
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 time | |
import datetime | |
# credit: squiguy https://stackoverflow.com/a/13891070 | |
t_stamp = time.time() | |
t_stamp_string = datetime.datetime.fromtimestamp(t_stamp).strftime('%Y-%m-%d %H:%M:%S') | |
# output: 2019-01-25 12:06:02 | |
t_stamp_string = datetime.datetime.fromtimestamp(t_stamp).strftime('%Y.%m.%d.%H.%M.%S') | |
# output: 2019.01.25.12.07.16 | |
t_stamp_string = datetime.datetime.fromtimestamp(t_stamp).strftime('%Y%m%d%H%M%S') | |
# output: 2019.01.25.12.07.16 | |
t_stamp_string = datetime.datetime.fromtimestamp(t_stamp).strftime('%Y%m%d_%H%M%S') | |
# output: 20190125_120804 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment