Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 537
NothingToSeeHere Avatar asked Feb 10 '23 15:02

NothingToSeeHere


1 Answers

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) %>

like image 101
Collin Graves Avatar answered May 08 '23 13:05

Collin Graves