Created
March 25, 2014 13:07
-
-
Save fredrikaverpil/9761465 to your computer and use it in GitHub Desktop.
Get "last modified" date of file #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 os, time | |
def getYYMMDD(filepath): | |
statbuf = os.stat(filepath) | |
date = time.localtime((statbuf.st_mtime)) | |
# Debug | |
#print str(date) | |
# Extract out the year, month and day from the date | |
year = date[0] | |
month = date[1] | |
day = date[2] | |
# YY | |
strYear = str(year)[2:] | |
# MM | |
if (month <=9): | |
strMonth = '0' + str(month) | |
else: | |
strMonth = str(month) | |
# DD | |
if (day <=9): | |
strDay = '0' + str(day) | |
else: | |
strDay = str(day) | |
return (strYear+strMonth+strDay) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment