Last Updated: February 25, 2016
· mriddle

Ruby: Converting date from one timezone to another

I always forget how to do date/time conversion in Ruby so I thought I would dump it here for future reference.

I wanted to convert from +00:00 to +10:00 but it obviously works for any offset.

# Parse
dt = DateTime.parse(issue.updated_at)
# Convert
local_dt = dt.new_offset(
# Display
local_dt.strftime("%I:%M %p - %d-%b-%Y")