Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


= TZInfo -- Daylight-savings aware timezone support for Ruby

TZInfo[] uses the tz database 
( to provide
daylight-savings aware transformations between times in different timezones.
This is the same database as used for zoneinfo on Unix machines.

The tz database has been imported (using TZDataParser) and turned into a set of
Ruby classes (which are packaged with this release).

== Example usage

To convert a time in UTC, to a local time in the America/New_York timezone, you
can do the following:

  require_gem 'tzinfo'
  include TZInfo
  tz = Timezone.get('America/New_York')
  local = tz.utc_to_local(,8,29,15,35,0))
To convert from a local time to UTC, the local_to_utc method can be used:

  utc = tz.local_to_utc(local)
To get information about the rules in force at a particular UTC or local time,
the Timezone.period_for_utc and Timezone.period_for_local methods can be used.
Both of these methods return TimezonePeriod objects. The following gets the 
identifier for the period (in this case EDT).

  period = tz.period_for_utc(,8,29,15,35,0))
  id = period.zone_identifier
In all the above examples, instances of Time can be used instead of DateTime.
Timezone.utc_to_local and Timezone.local_to_utc both return the type they are 

You can get the current local time in a Timezone with the method:

  now =
You can also access Timezones by Country (ISO 3166 country code). The following 
gets all the Timezone identifiers for the US:

  us = Country.get('US')
  timezones = us.zone_identifiers
The above covers the most common uses of Timezone and Country. For more detail,
see the API documentation for the individual classes.

== Download

The latest version of TZInfo can be found at


API documentation can be found at 


== Installation

The preferred method of installing TZInfo is through the GEM file (RubyGems[] required):

  % gem install tzinfo-x.y.z.gem
or to automatically download and install:

  % gem install tzinfo --remote

== License

TZInfo is released under the MIT[] license.

== Support

Please post to the TZInfo Users mailing list (
if you require assistance or have any suggestions.

Alternatively, you can contact the author Philip Ross directly at
Something went wrong with that request. Please try again.