Skip to content

Instantly share code, notes, and snippets.

@wilkie
Created July 21, 2013 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilkie/6048011 to your computer and use it in GitHub Desktop.
Save wilkie/6048011 to your computer and use it in GitHub Desktop.
Using timezones in Ruby with simply the tzinfo database.
require 'tzinfo'
# https://rubygems.org/gems/tzinfo
# http://tzinfo.rubyforge.org/doc/
time = Time.now
tz = TZInfo::Timezone.get('America/New_York')
local = tz.utc_to_local(time.utc)
puts local
tz = TZInfo::Timezone.get('America/Denver')
local = tz.utc_to_local(time.utc)
puts local
source 'https://rubygems.org'
gem "tzinfo"
gem "tzinfo-data"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment