Bruno Miranda's Notebook

Personal Blog about Ruby on Rails, XHTML, CSS, and Design

Very useful plugin that formats timestamps to human-friendly relative dates.

<%= 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:

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

Comments: 0 (view/add your own) Tags: date, ruby, time