user310525 user310525 -5 years ago 104
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download