Post by Hendy Irawan on June 11th, 2007

relative_time_helpers Plugin: time_ago_in_words on Steroids

From Basecamp's screenshot

relative_time_helpers is a straightforward, but very useful Rails plugin by Rick Olson that formats timestamps to human-friendly relative dates. You're probably already using Rails' built-in time_ago_in_words helper in your applications, but Rick's relative_time gives even better results:

<%= relative_time(Time.now) %>
# today
<%= relative_time(1.day.ago) %>
# yesterday
<%= relative_time(1.day.from_now) %>
# tomorrow
<%= relative_time_span([Time.now, 5.days.from_now]) %>
# May 17th - 22nd

To install it:

script/plugin install http://ar-code.svn.engineyard.com/plugins/relative_time_helpers

[Post to Twitter] Tweet This

2 Responses to “relative_time_helpers Plugin: time_ago_in_words on Steroids”

  1. #1
    Dr J Says:

    I was just about to write this same type of plugin. Thanks so much for saving me the trouble!

  2. #2
    Hendy Irawan Says:

    Dear Dr J:

    Yaay! I'm so happy for you... I do agree with you. It's probably one of the most directly-useful plugins that looks very simple on the surface :-)