One clever way to format time using Ruby is by using a Rails method called "time_ago_in_words". This method translates the hard to read default format for a date and time, making it more human friendly. Here is a quick example:
time_ago_in_words(Time.now) # => less than a minute
Here is how to use it in a controller:
class UsersController
def index
helpers.time_ago_in_words(Time.now)
end
end
Top comments (0)