method

relative_time_in_words

rails latest stable - Class: ActionView::Helpers::DateHelper

Method not available on this version

This method is only available on newer versions. The first available version (v8.1.1) is shown here.

relative_time_in_words(from_time, options = {})
public

Like time_ago_in_words, but adds a prefix/suffix depending on whether the time is in the past or future. You can use the scope option to customize the translation scope. All other options are forwarded to time_ago_in_words.

relative_time_in_words(3.minutes.from_now) # => "in 3 minutes"
relative_time_in_words(3.minutes.ago) # => "3 minutes ago"
relative_time_in_words(10.seconds.ago, include_seconds: true) # => "less than 10 seconds ago"

See also #time_ago_in_words