Skip to content

Instantly share code, notes, and snippets.

@ezkl
Created July 2, 2011 02:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezkl/1059685 to your computer and use it in GitHub Desktop.
Save ezkl/1059685 to your computer and use it in GitHub Desktop.
distance_of_time_ago & time_ago_in_words
ruby-1.9.2-p180 :018 > class Ack
ruby-1.9.2-p180 :019?> include ActionView::Helpers::DateHelper
ruby-1.9.2-p180 :020?> end
=> Ack
ruby-1.9.2-p180 :021 > dh = Ack.new
=> #<Ack:0x00000101dfb018>
ruby-1.9.2-p180 :022 > dh.time_ago_in_words("2011-05-05 19:49:46")
=> "about 1 month"
ruby-1.9.2-p180 :023 > dh.distance_of_time_in_words_to_now("2011-05-05 19:49:46")
=> "about 1 month"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment