I have a script here (not my own) which calculates the length of a movie in my satreceiver. It displays the length in minutes:seconds
I want to have that in hours:minutes
What changes do I have to make?
This is the peace of script concerned:
if len > 0:
len = "%d:%02d" % (len / 60, len % 60)
else:
len = ""
res = [ None ]
I already got the hours by dividing by 3600 instead of 60 but can't get the minutes...
Thanks in advance
Peter
To get the hours and minutes from a date, call the getHours() and getMinutes() methods on the date object. The getHours method returns the hours and the getMinutes() method returns the minutes in the specified date.
hours = secs / 3600
minutes = secs / 60 - hours * 60
len = "%d:%02d" % (hours, minutes)
Or, for more recent versions of Python:
hours = secs // 3600
minutes = secs // 60 - hours * 60
len = "%d:%02d" % (hours, minutes)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With