Calculating Elapsed Time

Jean Johnson jeanjohnson51 at yahoo.com
Tue Dec 6 15:52:13 EST 2005


I'm using an old version of python (2.1) and datetime
isn't available until Python 2.3.  I can't upgrade my
python.

--- skip at pobox.com wrote:

> 
>     Jean> How do I calculate the elapsed time?
> 
> Where t1_s and t2_s reference time strings in the
> format you describe:
> 
>     import datetime
>     import time
> 
>     fmt = "%b %d %Y  %H:%M:%S"
> 
>     t1 = datetime.datetime(*time.strftime(t1_s,
> fmt)[:6])
>     t2 = datetime.datetime(*time.strftime(t2_s,
> fmt)[:6])
>     dt = t2 - t1
> 
> should do the trick.
> 
> Skip
> 
> 



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 




More information about the Python-list mailing list