time difference interms of day
Steve Holden
steve at holdenweb.com
Sun Oct 24 14:18:18 EDT 2010
On 10/24/2010 1:55 PM, mukkera harsha wrote:
> Hello
> I was wondering if there is an existing function that would let me
> determine the difference in time. To explain:
>
> Upon starting a program:
>
> startup = time.time()
>
> After some very long processing:
> now = time.time()
>
>
> On, doing now - startup I want the program to return in terms of days. How ?
>
>
> Thanks,
>
> Harsha.
>
You'd probably be better off using the datetime module. That way you can
store datetime.datetime.now() at the start of your run and subtract
datetime.datetime.now() at the end, giving you a datetime.delta object
which contains days, seconds and microseconds:
>>> import datetime
>>> t1 = datetime.datetime.now()
[waited a while]
>>> t2 = datetime.datetime.now()
>>> t2-t1
datetime.timedelta(0, 16, 509000)
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon 2011 Atlanta March 9-17 http://us.pycon.org/
See Python Video! http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list