Skip to content

Instantly share code, notes, and snippets.

@fredrikaverpil
Created March 25, 2014 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrikaverpil/9761465 to your computer and use it in GitHub Desktop.
Save fredrikaverpil/9761465 to your computer and use it in GitHub Desktop.
Get "last modified" date of file #python
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