How can I get the utc offset in Rails? How can I get the utc offset in Rails? ruby ruby

How can I get the utc offset in Rails?


If you need to take daylight savings time into account, you can use something like this:

Time.now.in_time_zone('America/New_York').utc_offset


require 'time'p Time.zone_offset('EST') #=> -18000  #(-5*60*60)


Time.now.in_time_zone('Europe/London').formatted_offset# => "+01:00"

For a string arguably more usable...