From: Steven Jenkins Date: 2005-02-24T06:34:07+09:00 Subject: Re: parsing a time in a specific timezone Paul Brannan wrote: > I can use Time.parse to parse a timestamp in the local timezone, e.g.: > > irb(main):001:0> require 'time' > => true > irb(main):002:0> t = Time.parse('20050103-14:31:26') > => Mon Jan 03 14:31:26 EST 2005 > > But how can I parse the above timestamp in a timezone other than the > local timezone (e.g. I want the method to assume that the timestamp is > in UTC)? ENV['TZ'] = 'UTC' or even easier, append a Z to the string: $ irb irb(main):001:0> require 'time' => true irb(main):002:0> Time.parse('20050103-14:31:26') => Mon Jan 03 14:31:26 PST 2005 irb(main):003:0> Time.parse('20050103-14:31:26Z') => Mon Jan 03 14:31:26 UTC 2005 Steve