Skip to content

Instantly share code, notes, and snippets.

@andrew
Created July 16, 2009 14:18
Show Gist options
  • Select an option

  • Save andrew/148426 to your computer and use it in GitHub Desktop.

Select an option

Save andrew/148426 to your computer and use it in GitHub Desktop.
def format_datetime_ago(time)
formatted = time.strftime('%d %b %y at %I:%M%p')
if time > 5.days.ago
formatted = "#{time_ago_in_words(time)}"
formatted.insert(0, 'in ') if time > Time.now
formatted.insert(formatted.length, ' ago') if time < Time.now
end
content_tag :abbr, formatted, :title => time.iso8601
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment