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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Apr-11 16:03 UTC
Re: How to convert a "time difference" into "x days, y hours..."
On Apr 11, 4:48 pm, Tom Ha <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> Does RoR have any nifty helper for this ? > > Thanks a lot for any hint! > Tom > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-Apr-11 16:04 UTC
Re: 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 ?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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Ha
2010-Apr-11 16:08 UTC
Re: How to convert a "time difference" into "x days, y hours..."
Great! Thanks a lot, guys! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.