I have a script that needs to make a difference between 2 dates collection of some files
In case the script collects the date of a .txt file (dt_log) and the current date of the system (dt_sys) and my difficulty is to find the difference between these 2 dates
Example
The file was created on 07/20/2018 10:05:55 AM The system date is 7/25/2018 11:10:02 AM
The return I would need to print is 120 hours (5 days = 120 hours)
Is it possible to do this?
Here's some code snippet:
# LOG DATE AND SYSTEM DATE
## LOG dt_log = os.stat(log[0]) dt_log = time.ctime(dt_log.st_ctime) dt_log = dt_log.split(' ') print("Hora da Log: ", dt_log[3])
## SYSTEM dt_sys = time.time() dt_sys = time.ctime(dt_sys) dt_sys = dt_sys.split(' ') print("Hora do Sys: ", dt_sys[3])
# CALCULATE DIFFERENCE BETWEEN DATES calc = int(dt_log[3] - dt_sys[3])
Code that takes the date of the file and the system:
# LOG DATE AND SYSTEM DATE
## LOG
dt_log = os.stat(log[0])
dt_log = time.ctime(dt_log.st_ctime)
#dt_log = dt_log.split(' ')
print("Hora da Log: ", dt_log)
## SYSTEM
dt_sys = time.time()
dt_sys = time.ctime(dt_sys)
#dt_sys = dt_sys.split(' ')
print("Hora do Sys: ",dt_sys)