Skip to content

Instantly share code, notes, and snippets.

@brentvollebregt
Created November 5, 2017 06:51
Show Gist options
  • Save brentvollebregt/43c5a436816eef4a0750a3dee5cf558f to your computer and use it in GitHub Desktop.
Save brentvollebregt/43c5a436816eef4a0750a3dee5cf558f to your computer and use it in GitHub Desktop.
Change/Set Modification and Last Access Time With Python
import os
import time
import datetime
fileLocation = r""
year = 2017
month = 11
day = 5
hour = 19
minute = 50
second = 0
date = datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute, second=second)
modTime = time.mktime(date.timetuple())
os.utime(fileLocation, (modTime, modTime))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment