Time ago in words
07 Mar 22
Once upon a time, I spent an unreasonable amount of time trying to write a class
to convert the created_at
timestamp of a message into something more readable
and user friendly.
Instead of telling the user a message was sent at 12:01 pm UTC, I wanted to be able to tell the user a message was sent 5 minutes ago.
In the end I stopped persevering because there were so many edge cases that kept cropping up. If only I knew about the time_ago_in_words helper back then!
# actionview/lib/action_view/helpers/date_helper.rb
time_ago_in_words(5.minutes.ago) # => 5 minutes ago