distance_of_time_in_words

August 7th, 2009 by Radar

I was infatuated with this method when I first saw Rails but I’ve seen a couple of people recently express that Rails’ built in distanceoftimeinwords is not accurate enough, showing something like “about 2 years” rather than “2 years, 21 days, 5 hours, and 6 minutes”. With some help from chendo at Mocra (where I work) I’ve made a new distanceoftimeinwords which should be a drop-in replacement for the old crappy one. To install it, use: script/plugin install git://github.com/radar/dotiw.git. This also comes with another method if you’re still picky about the output: distanceoftimeinwords_hash which gives you a Hash containing keys in your native tongue. The README should give you a good guide of what other options it supports too.

2 Responses to “distance_of_time_in_words”

  1. Double Shot #514 « A Fresh Cup Says:

    [...] distanceoftimeinwords – This version by Ryan Bigg removes the vagueness in the Rails core version. [...]

  2. Brad Wetli Says:

    Awesome. Just what I needed, my site is charging based on time, and “about 2 hours ago” was not going to cut it.

    thanks.

Leave a Reply