Need help with rails-timeago?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

213 Stars 40 Forks MIT License 193 Commits 1 Opened issues


A Rails helper for time tags that can be used with the jQuery Timeago plugin.

Services available


Need anything else?

Contributors list


Gem Version Build Status

rails-timeago provides a timeago_tag helper to create time tags usable for jQuery Timeago plugin.


Add this line to your

gem 'rails-timeago', '~> 2.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-timeago

Use bundled JavaScript with Sprockets

Note: The bundled JavaScript can only be used with sprockets. Rails-webpacker cannot load scripts bundled with the gem. If you use rails-webpacker you need to install, load, and setup jquery-timeago on your own.

To use bundled jQuery Timeago plugin add this require statement to your

//= require rails-timeago

This will also convert all matching time tags on page load.

Use the following to also include all available locale files:

//= require rails-timeago-all

If using a recent Rails with

, jQuery might not be present anymore. You need to add
to your
and load it, e.g.:
//= require jquery
//= require rails-timeago
//= require rails-timeago-all


Use the timeago_tag helper like any other regular tag helper:

Available options:

date_only Only print date as tag content instead of full time. (default:


format A time format for localize method used to format static time. (default:


limit Set a limit for time ago tags. All dates before given limit will not be converted. (default:


force Force time ago tag ignoring limit option. (default:


default String that will be returned if time is

. (default:

title A string or block that will be used to create a title attribute for timeago tags. It set to nil or false no title attribute will be set. (default:

proc { |time, options| I18n.l time, format: options[:format] }

All other options will be given as options to the time tag helper. The above options can be assigned globally as defaults using

Rails::Timeago.default_options limit: proc { 20.days.ago }

A global limit should always be given as a block that will be evaluated each time the rails

helper is called. That avoids the limit becoming smaller the longer the application runs.


rails-timeago 2 ships with a modified version of jQuery timeago that allows to include all locale files at once and set the locale via an option or per element via the


The following snippet will print a script tag that set the jQuery timeago locale according to your


Just insert it in your application layout's html head. If you use another I18n framework for JavaScript you can also directly set

. For example:
jQuery.timeago.settings.lang = $('html').attr('lang')

Do not forget to require the needed locale files by either require

in your
file or require specific locale files:
//= require locales/
//= require locales/

Note: English is included in jQuery timeago library, but can be easily override by include an own file that defines

. See a locale file for more details.

rails-timeago includes locale files for the following locales taken from jQuery Timeago.

Your customized jQuery locale files must be changed to work with rails-timeago 2. Instead of defining your locale strings as

you need to define them like this:
jQuery.timeago.settings.strings["en"] = {


MIT License

Copyright (c) 2014, Jan Graichen

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.