Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rails plugin for dead-simple timezone support

branch: master
1 comment

Better specs for clarification

Signed-off-by: PJ Hyett <>
latest commit 17d284276d
Steve Iannopollo siannopollo authored pjhyett committed
Octocat-spinner-32 lib Disregarding server offsets and using the time in utc March 21, 2009
Octocat-spinner-32 spec Better specs for clarification March 21, 2009
Octocat-spinner-32 LICENSE zoned import April 30, 2008
Octocat-spinner-32 README zoned import April 30, 2008
Octocat-spinner-32 init.rb zoned import April 30, 2008
Octocat-spinner-32 install.rb zoned import April 30, 2008

This plugin is the simplest way to add local times to your app.


1) Call the javascript function Timezone.set() to set a timezone cookie

    eg: Hook it into the authentication system
      Logging in:
      <% form_for @login, { :html => { :onsubmit => "Timezone.set()" } %>
      Logging out:
    eg: Initialize it automatically
      window.onload = Timezone.set

2) Use it: <%= z(@post.created_at).strtime("%D") %>

If cookies[:timezone] is set it will convert the time to the user's 
local time, otherwise it will do nothing.

You don't need to have AR save your time in UTC, the plugin will determine 
your server's offset and adjust accordingly.
Something went wrong with that request. Please try again.