datetime difference in python
for proc in psutil.process_iter():
if proc.name == "monit":
today = datetime.datetime.now()
current_time = today.strftime('%Y-%m-%d %H:%M:%S')
proc_start_time = time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(proc.create_time))
print current_time
print proc_start_time
print (current_time - proc_start_time).seconds
I am not able to find difference between two datetimes. Can't subtract
them give Error -
TypeError: unsupported operand type(s) for -: 'str' and 'str'
No comments:
Post a Comment