bertramseiner-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Dec-21 22:08 UTC
How to get a well formatted Timespan
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? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 21, 2007, at 4:08 PM, bertramseiner-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> > 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?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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---