Created
March 31, 2020 22:18
-
-
Save Mlawrence95/7646efcbd0422e7573c5387995066e59 to your computer and use it in GitHub Desktop.
Use python's time library to print the date as a single string in m/d/y format, GMT. Useful for adding timestamps to filenames
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
import time | |
def get_timestamp(): | |
""" | |
Print the date in m/d/y format, GMT | |
>>> get_timestamp() | |
'3_31_2020' | |
""" | |
t = time.gmtime() | |
month, day, year = str(t.tm_mon), str(t.tm_mday), str(t.tm_year) | |
return "_".join([month, day, year]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment