Possible Duplicate:
Calculate difference in days ActiveSupport:TimeWithZone in the most “rubyish” style?
I just needed to print out the number of days something was created_at to now.
I tried something like this but it keeps printing 0.
(Date.today – p.created_at).to_i
More example, when something was created_at(09-01-2012) the code should print the number 3 for x days ago from today’s date(09-04-2012).
You can use the
distance_of_time_in_wordshelper in the views. If you want something with better precision, I co-authored a gem called dotiw which provides the same helper method.