Steve Holden wrote: > 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) >>>>
Or using mxDateTime: >>> from mx import DateTime >>> start = DateTime.now() >>> stop = DateTime.now() >>> print stop - start 00:00:04.26 http://www.egenix.com/products/python/mxBase/mxDateTime/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 26 2010) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list