from datetime import datetime startTime = datetime.now() #do something #Python 2: print datetime.now() - startTime #Python 3: print(datetime.now() - startTime)