-3

I am fairly new to ruby. I have a date value say "2014-12-15T19:56:59Z" and an offset value say "-06:00". How can I convert the given date time in the timezone given by offset value.

Akshay
  • 153
  • 3
  • 14

1 Answers1

2

Using Time::parse and Time#localtime:

require 'time'

t = Time.parse('2014-12-15T19:56:59Z')
#=> 2014-12-15 19:56:59 UTC

t.localtime('-06:00')
#=> 2014-12-15 13:56:59 -0600
Stefan
  • 109,145
  • 14
  • 143
  • 218