This may be ridiculously easy, but what is the best way to format/ calculate how much time has passed since a record was created. I have a created_at field in my table and I want to say that a record was created XXXX ago, for instance 2 days 1 hour ago. Thanks, JB --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails to the rescue - "time_ago_in_words" will do what you need time_ago_in_words(Time.now - (10.hours + 25.minutes)) # outputs => "About 10 hours" On Aug 24, 9:49 am, Jables <brun3...-Meo6Lv8EUjg3uPMLIKxrzw@public.gmane.org> wrote:> This may be ridiculously easy, but what is the best way to format/ > calculate how much time has passed since a record was created. I have > a created_at field in my table and I want to say that a record was > created XXXX ago, for instance 2 days 1 hour ago. > Thanks, > JB--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks dang. On Aug 23, 5:11 pm, dang <dgr...-vQs5aMGR+7nQT0dZR+AlfA@public.gmane.org> wrote:> Rails to the rescue - "time_ago_in_words" will do what you need > > time_ago_in_words(Time.now - (10.hours + 25.minutes)) # outputs => > "About 10 hours" > > On Aug 24, 9:49 am, Jables <brun3...-Meo6Lv8EUjg3uPMLIKxrzw@public.gmane.org> wrote: > > > This may be ridiculously easy, but what is the best way to format/ > > calculate how much time has passed since a record was created. I have > > a created_at field in my table and I want to say that a record was > > created XXXX ago, for instance 2 days 1 hour ago. > > Thanks, > > JB--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---