intervals = ('weeks', 604800), ('days', 86400), ('hours', 3600), ('minutes', 60
    ), ('seconds', 1)

def display_time(seconds, granularity=2):
    result = []
for name, count in intervals:
    value = seconds // count
if value:
    seconds -= value * count
if value == 1:
    name = name.rstrip('s')
result.append('{} {}'.format(value, name))
return ', '.join(result[:granularity])
Python function to convert seconds into minutes, hours, and days