Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Time Difference

Reply
Thread Tools

Time Difference

 
 
GMane Python
Guest
Posts: n/a
 
      12-17-2004
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



 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      12-17-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert time to ruby time to calculate the time difference. Ruwan Budha Ruby 4 03-09-2011 04:43 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
time.clock() or time.time() peterbe@gmail.com Python 8 08-05-2005 01:51 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
delta time = time stop - time start engsol Python 2 01-26-2004 12:06 PM



Advertisments