Andy McKay

Nov 22, 2006

Timezones in Rails

Are a bit of a mess. If you want an easy life assume that your app is only going to be ever run in one timezone and go to environment.rb and set: ENV['TZ'] = 'GMT' 

The problem I had is that it seems rails is doing a cast of the date. I set a date as GMT, put into the database, a timestamp with time zone field. Then when you get it out it casts into my local timezone:

sa = sa.datepoint =,12,13) => Wed Dec 13 00:00:00 UTC 2006 .. zz = Thingy.find(:all)[1] zz.datepoint => Wed Dec 13 00:00:00 PST 2006

If you are having similar problems try trawling through the following posts on this issue. 

On a light note, got Plone 3.0 up and running and made a first completely useless check-in on it. Yay.