Search code examples
ruby-on-railshelper

Is there a time ahead words in rails (opposite of time_ago_in_words)


Is there a rails helper opposite of time_ago_in_words ? I can't seem to find the opposite...where I can have 7 days from now converted to "in about 1 week".

I can get this to work for the past:

 <%= time_ago_in_words( milestone.due_date) %>

But this doesn't work for the future:

   <%= time_ahead_in_words(milestone.due_date) %>

stumped.


Solution

  • You can use distance_of_time_in_words(from_time, to_time = 0, options = {}) instead.

    So you could set it up like so:

    <%= distance_of_time_in_words(Time.now, milestone.due_date) %>