← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #270830]: How to get difference of 2 dates in python

 

Question #270830 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/270830

RaiMan proposed the following answer:
well done ;-)

--- Is there any simpler way of doing this?
simpler - I do not think so.

shorter - yes
from time import strptime
is not needed here, since you do not use it.

if you need it more than once, then you could make a function:

def nowDelta(givenTime):
   from datetime import datetime
   return datetime.now() - datetime.strptime(givenTime,"%Y%m%d%H%M%S")

and use it
out="20150827173103"
tdelta = nowDelta(out)
print tdelta

does the same, but hides the gory details?

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.