You can try with this:
def time_diff(start_time, end_time)
seconds_diff = (start_time - end_time).to_i.abs
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
minutes = seconds_diff / 60
seconds_diff -= minutes * 60
seconds = seconds_diff
"#{hours.to_s.rjust(2, '0')}:#{minutes.to_s.rjust(2, '0')}:#{seconds.to_s.rjust(2, '0')}"
# or, as hagello suggested in the comments:
# '%02d:%02d:%02d' % [hours, minutes, seconds]
end
And use it:
time_diff(Time.now, Time.now-2.days-3.hours-4.minutes-5.seconds)
# => "51:04:04"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…