Time Difference

Discussion in 'Python' started by GMane Python, Dec 17, 2004.

  1. GMane Python

    GMane Python Guest

    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
     
    GMane Python, Dec 17, 2004
    #1
    1. Advertising

  2. GMane Python

    Peter Hansen Guest

    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
     
    Peter Hansen, Dec 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    12,610
  2. flamesrock
    Replies:
    8
    Views:
    551
    Hendrik van Rooyen
    Nov 24, 2006
  3. Ruwan Budha
    Replies:
    4
    Views:
    1,193
    Kirk Haines
    Mar 9, 2011
  4. Nick Timkovich
    Replies:
    0
    Views:
    84
    Nick Timkovich
    Feb 25, 2014
  5. Skip Montanaro
    Replies:
    0
    Views:
    83
    Skip Montanaro
    Feb 25, 2014
Loading...

Share This Page