Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - How to display the time created like twitter

please take a look here: http://twitter.com/#!/techcrunch

Notice that time is displayed with the following logic:

  • If created_at, is under 24hrs, it display XXX hours ago, or 1 hour ago
  • If created_at, is over 24hrs, it display the X Feb

Does Rails have this capability built in or is a helper needed? If so, what's the smart way to solve for this type of output?

Thanks

like image 831
AnApprentice Avatar asked Feb 07 '11 01:02

AnApprentice


1 Answers

You are probably looking for the time_ago_in_words helper method.

like image 126
Martins S. Avatar answered Oct 13 '22 00:10

Martins S.