user310525 user310525 - 10 months ago 40
Ruby Question

"Ago" date/time functions in Ruby/Rails

I was wondering if there's a way in Rails to calculate time stamp like - half a minute ago, 2 minute ago, 1 day ago etc. Something like twitter real time date stamp.

I want to know if Ruby/Rails has a built-in function for such date-time conversion?


You can use:


Or in your views you have the helpers:

distance_of_time_in_words(from_time, to_time)

Check the API for details and more options.