Read more

Ruby: Convert a time string to your local time zone

Arne Hartherz
August 31, 2011Software engineer at makandra GmbH

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
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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.

Posted by Arne Hartherz to makandra dev (2011-08-31 11:45)