# How to get a well formatted Timespan

**URL:** <https://www.ruby-forum.com/t/how-to-get-a-well-formatted-timespan/123911>\
**Category:** Rails\
**Created:** [December 21, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/how-to-get-a-well-formatted-timespan/123911 "2007-12-21T23:08:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 21, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/how-to-get-a-well-formatted-timespan/123911/1 "2007-12-21T23:08:55Z")

</div>

Hi there,

i have some problems getting a timespan to a nice string. I have a  
Time when my db entry was created. Now i want to output how old this  
entry is.

When i subtract the Time from Time.now i get an float value but cannot  
create some new time from this value to get an Formatted string of the  
Timespan it presents. What can i use to create an output string for  
this?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 21, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/how-to-get-a-well-formatted-timespan/123911/2 "2007-12-21T23:44:01Z")

</div>

On Dec 21, 2007, at 4:08 PM, removed\_email\_address@domain.invalid wrote:

> this?  
> Subtracting one Time from another gives you the difference in seconds.  
> If you want some nice English descriptive phrase, such as “about one  
> month,” look at the distance\_of\_time\_in\_words Date Helpers:

[http://railsmanual.com/module/ActionView::Helpers::DateHelper#distance\_of\_time\_in\_words\_to\_now](http://railsmanual.com/module/ActionView::Helpers::DateHelper#distance_of_time_in_words_to_now)
