Time Zones and Rails

Local

irb(main):006:0> date = “2014-04-01”
=> “2014-04-01”
irb(main):007:0> begin_str = “#{date.to_s} #{TimeOfDay.new(0,0,0)} America/Los_Angeles”
=> “2014-04-01 00:00:00 America/Los_Angeles”
irb(main):008:0> begin_day = Time.strptime(begin_str, “%Y-%m-%d %H:%M:%S %Z”).utc
=> 2014-04-01 07:00:00 UTC

Production

irb(main):001:0> date = “2014-04-01”
=> “2014-04-01”
irb(main):002:0> begin_str = “#{date.to_s} #{TimeOfDay.new(0,0,0)} America/Los_Angeles”
=> “2014-04-01 00:00:00 America/Los_Angeles”
irb(main):003:0> begin_day = Time.strptime(begin_str, “%Y-%m-%d %H:%M:%S %Z”).utc
=> 2014-04-01 00:00:00 UTC

*headdesk*

Leave a Reply

Your email address will not be published. Required fields are marked *