-7

Hi I have a database column named total time which is the difference between two timestamps in seconds format. How can I convert it into minutes using python?

blackwindow
  • 437
  • 1
  • 8
  • 25
  • Possible duplicate of [Python Time Seconds to h:m:s](http://stackoverflow.com/questions/775049/python-time-seconds-to-hms) – koxt Feb 05 '17 at 15:18

1 Answers1

1
seconds = 12345
minutes= float(seconds)/60
avg_minutes = seconds // 60
print minutes
print avg_minutes
import datetime
formatedtime = datetime.timedelta(seconds=94513)
print str(formatedtime)
Himanshu dua
  • 2,496
  • 1
  • 20
  • 27
  • I've tried this. But for example I've seconds = -897 and when I do this method I get minutes = -15, instead of exact minutes(-14.95) – blackwindow Jul 24 '15 at 07:59
  • Okay that works :) How can I convert it into `hour:minute:second` format other than just the integer result? – blackwindow Jul 24 '15 at 08:34