"Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Basically I used the datetime module and timedelta objects to calculate a > difference between two times. Now I'm trying to figure out how I make > that time delta a string HH:MM:SS to show elapsed time. I've spent tons > of time looking at the module's documentation but I'm not seeing how those > methods will help me. Can anyone help me with this? > Here's what I'm trying to do, assum that resultsDict is a dictionary of > objects that have various pieces of information including a start time and > a stop time that are strings which I extracted from a file in an earlier > part of the program. I use regEx to split up the hours, minutes, and > seconds and create timedelta objects, which I then subtract to get the > different. What I need is to get the value in duration as HH:MM:SS as a > string: > >
>From the Python console: >>> startTime = datetime.timedelta(seconds=45,minutes=22,hours=10) >>> stopTime = datetime.timedelta(seconds=25,minutes=2,hours=4) >>> delta = startTime-stopTime >>> time.strftime("%H:%M:%S",time.gmtime(delta.seconds)) '06:20:20' -- Paul -- http://mail.python.org/mailman/listinfo/python-list