Simon Rentzke

Blue Blistering Barnacles

Timezone value from offset #rails

Some apis just return a timezone offset from UTC. For example Facebook

Need to convert it to a timezone name?

Rails Active Support to the rescue, you just need to do something like this:

utc_offset_in_hours = 10
time_zone = ActiveSupport::TimeZone[utc_offset_in_hours].name
=> "Brisbane"
Back to Blog