How to convert a "time difference" into "x days, y hours..."

Hi there,

how can I convert something like...

  future_datetime - past_datetime (which results in a float)

into something like...

  "21 days, 2 hours, 53 minutes, 1 seconds" ?

Does RoR have any nifty helper for this ?

Thanks a lot for any hint!
Tom

Hi there,

how can I convert something like...

future_datetime - past_datetime (which results in a float)

into something like...

"21 days, 2 hours, 53 minutes, 1 seconds" ?

Have a look at distance_of_time_in_words
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695

Fred

Hi there,

how can I convert something like...

future_datetime - past_datetime (which results in a float)

into something like...

"21 days, 2 hours, 53 minutes, 1 seconds" ?

Does RoR have any nifty helper for this ?

Not that I know of, but there's examples out there...

http://www.google.com/search?q=rails+seconds+to+hours+minutes

This one seems to have the days bit...

http://stufftohelpyouout.blogspot.com/2010/02/seconds-to-days-minutes-hours-seconds.html

Great! Thanks a lot, guys!