[Rails] Re: formatted date down-counter - help!

Alex Wayne
Wed, 10 May 2006 21:59:13 -0000

rh wrote:
> I''d like to have a count down to a certain date, but display it in
> words, such as "123 days away" or something.  I''m aware
of the function
> "distance_of_time_in_words_to_now()", which will display
"about 6 hours"
> or "12 days" or something like that, but how can I get it to
reverse?
> Pass it a date for future reference, then it will error or be negative,
> right?
>
> Any thoughts?  Thanks...

You want distance_of_time_in_words
http://api.rubyonrails.com/classes/ActionView/Helpers/DateHelper.html#M000466

@time_to_event = distance_of_time_in_words(Time.now, 123.days.from_now)