In ruby, how can I get current time in a given timezone? I know the offset from UTC, and want to get the current time in the timezone with that offset.
I tried a gem install active_support, it installed activesupport-3.00, which gave me an error:
"You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
tzinfo is a gem that ActiveSupport uses -- it was a little cleaner for my purposes, doesn't have any external dependencies -- the downside is that it appears to leave everything looking like it is UTC, so if you want your timezones to look correct, gem install activerecord will install everything you need. I'm including this answer mostly for reference for others that run into the same issue / googlability.
(use gem install tzinfo) to install the gem
require 'tzinfo'
zone = TZInfo::Timezone.get('US/Eastern')
puts zone.now
there are a number of different ways to get the timezones, but you can see a list using
TZInfo::Timezone.all