instance method time_ago_in_words

Ruby on Rails 3.1.12

Since v2.2.3

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

time_ago_in_words(from_time, include_seconds = false)

Like distance_of_time_in_words, but where to_time is fixed to Time.now.

Examples

time_ago_in_words(3.minutes.from_now)       # => 3 minutes
time_ago_in_words(Time.now - 15.hours)      # => about 15 hours
time_ago_in_words(Time.now)                 # => less than a minute

from_time = Time.now - 3.days - 14.minutes - 25.seconds
time_ago_in_words(from_time)      # => 3 days

Parameters

from_time req
include_seconds opt = false
Source
# File actionpack/lib/action_view/helpers/date_helper.rb, line 132
      def time_ago_in_words(from_time, include_seconds = false)
        distance_of_time_in_words(from_time, Time.now, include_seconds)
      end

Defined in actionpack/lib/action_view/helpers/date_helper.rb line 132 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::DateHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close