Calculating Elapsed Time
Fredrik Lundh
fredrik at pythonware.com
Tue Dec 6 15:49:28 EST 2005
Jean Johnson wrote:
> I have a start and end time that is written using the
> following:
>
> time.strftime("%b %d %Y %H:%M:%S")
>
> How do I calculate the elapsed time?
import time
FORMAT = "%b %d %Y %H:%M:%S"
t1 = time.strftime(FORMAT)
print t1
time.sleep(1)
t2 = time.strftime(FORMAT)
print t2
# later
s1 = time.mktime(time.strptime(t1, FORMAT))
s2 = time.mktime(time.strptime(t2, FORMAT))
print s2 - s1
</F>
More information about the Python-list
mailing list