Ruby on Rails
Timezone Conversion

Timezone Conversion in Ruby on Rails

Timezones aren’t very fun for anyone, but with a little knowledge, they can be easy in ruby on rails.

By far your best bet is to use the TZInfo gem

There’s a writeup on the 37signals blog about how to use this gem. Introducing TzTime

And one on caboo.se:
adding timezone to your rails app

Adding TZInfo to your Models

TZInfo is further made easier with ThriveSmart’s Timezone_fu so that you only have to specify has_timezone in your model, such as:

  class Event < ActiveRecord::Base
    has_timezone :fields => [ :start_datetime, :end_datetime]
  end

More Resources