By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,389 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Time Difference

P: n/a
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()

print <days> <hours> <minutes> <seconds>, now - startup

So, to print in a formatted way (D-H-M-S) the difference in time of startup
and now.

Thanks!
Dave

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
GMane Python 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()

print <days> <hours> <minutes> <seconds>, now - startup

So, to print in a formatted way (D-H-M-S) the difference in time of startup
and now.

from datetime import datetime
startTime = datetime.now() # processing.... endTime = datetime.now()
print 'elapsed', endTime - startTime

elapsed 0:00:09.063000

-Peter
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.