# Re: Time from seconds

**URL:** <https://www.ruby-forum.com/t/re-time-from-seconds/110865>\
**Category:** Rails\
**Created:** [July 31, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/re-time-from-seconds/110865 "2007-07-31T17:07:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![piet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@piet](https://www.ruby-forum.com/u/piet)\
**Post date:** [July 31, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/re-time-from-seconds/110865/1 "2007-07-31T17:07:59Z")

</div>

Something like:

def number\_to\_time(seconds)  
Time.at(seconds.to\_i-3600).strftime("%H:%M:%S")  
end

Piet.

---

<div class="post-metadata">

**Author:** ![piet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@piet](https://www.ruby-forum.com/u/piet)\
**Post date:** [July 31, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/re-time-from-seconds/110865/2 "2007-07-31T17:51:07Z")

</div>

Well it would be really nice and concise if that worked but  
unfortunately it doesn’t work for seconds \> 1.day i.e., it will show  
00:05:55 rather than 24:05:55.  
I would like a %H:%M:%S type output but with %H representing the  
number of hours which can be greater than 24.

On Jul 31, 4:07 pm, “Piet H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
