There's some secret that you should know before you make time scaling in ruby on rails specially to the view. I have little smile when seeing helper from a developer that make time helper like in twitter or facebook, example a moment ago, or 3 minutes ago, or 1 hour ago. Why you hurt your brain if Rails already supports it. I think that he doesnt know the secret, now let me tell you the secret:
distance_of_time_in_words_to_now
Reports the approximate distance in time between from Time to time now. Set include_seconds to true if you want more detailed approximations when distance less than 1 min. example :
<%= distance_of_time_in_words_to_now(from_time, include_seconds = false) %>
distance_of_time_in_words
This is the same like above, but you can get range of time from 2 dateTimes, example :
<%= distance_of_time_in_words_to_now(from_time, to_time = 0, include_seconds = false, options = {}) %>
below is table list from date range in many conditions:
0 - 29 secs # => less than a minute
30 secs to 1 min, 29 secs # => 1 minute
1 min, 30 secs to; 44 mins, 29 secs # => [2..44] minutes
44 mins, 30 secs to 89 mins, 29 secs # => about 1 hour
89 mins, 29 secs to 23 hrs, 59 mins, 29 secs # => about [2..24] hours
23 hrs, 59 mins, 29 secs to 47 hrs, 59 mins, 29 secs # => 1 day
47 hrs, 59 mins, 29 secs to 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
29 days, 23 hrs, 59 mins, 30 secs to 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month
59 days, 23 hrs, 59 mins, 30 secs to 1 yr minus 1 sec # => [2..12] months
1 yr to 1 yr, 3 months # => about 1 year
1 yr, 3 months to 1 yr, 9 months # => over 1 year
1 yr, 9 months to 2 yr minus 1 sec # => almost 2 years
2 yrs to max time or date # => (same rules as 1 yr)