Ruby: Convert a time string to your local time zone

If you have a time given in a different time zone than your local one, parsing will convert it for you:

>> Time.parse('September 2nd, 3pm PST')
=> 2011-09-03 01:00:00 +0200

Note that in pure Ruby you need to require "tzinfo" (Ruby 1.9) or require "time" (Ruby 1.8) for Time.parse to be available.

Arne Hartherz Over 12 years ago