Method: ActionView::Helpers::DateHelper#distance_of_time_in_words_to_now
- Defined in:
- actionview/lib/action_view/helpers/date_helper.rb
#distance_of_time_in_words_to_now ⇒ Object
Like distance_of_time_in_words
, but where to_time
is fixed to Time.now
.
time_ago_in_words(3.minutes.from_now) # => 3 minutes
time_ago_in_words(3.minutes.ago) # => 3 minutes
time_ago_in_words(Time.now - 15.hours) # => about 15 hours
time_ago_in_words(Time.now) # => less than a minute
time_ago_in_words(Time.now, include_seconds: true) # => less than 5 seconds
from_time = Time.now - 3.days - 14.minutes - 25.seconds
time_ago_in_words(from_time) # => 3 days
from_time = (3.days + 14.minutes + 25.seconds).ago
time_ago_in_words(from_time) # => 3 days
Note that you cannot pass a Numeric
value to time_ago_in_words
.
180 181 182 |
# File 'actionview/lib/action_view/helpers/date_helper.rb', line 180 def time_ago_in_words(from_time, = {}) distance_of_time_in_words(from_time, Time.now, ) end |