Formatting time calculation

Paul Nichols wrote:

I'm calculating the duration of an event by simply doing 'end_time -
start_time'. This outputs the time in seconds.

However, i'd like this to be displayed in hours, minutes and seconds in
HH:mm:ss format.

Is this possible?

I'm not aware of any Rails methods for this, so here is my implementation:

def format_time
   seconds = time % 60
   minutes = (time / 60) % 60
   hours = (time / 3600) % 60
   "#{hours}::#{minutes}::#{seconds}"
end