Rails ActiveRecord UTC time zone problem

I configured ActiveRecord in my environment.rb file to use UTC as follows:

config.active_record.default_timezone = :utc

I am using MySQL 5.0.x

In a table, called comments, model Comment, there is a field called created_at as :datetime. I basically get two different time shown on the mysql console based on the two following commands:

Comment.create # this will automatically set the time in :created_at Comment.create :created_at => Time.now

The time difference is 3 hours (apparently the difference of my time zone to UTC). If is set :utc conversion off in my environment, everything works fine. I even set the MySQL time conversion tables, but still won't work. Is there a way to set MySQL time zone correctly, and how?

What am I doing wrong? Greetings, Juergen

Time#now will return the current time for your timezone, and it won't get converted into UTC when you save it to the database. You need to qualify it with #utc:

Comment.create :created_at => Time.now.utc

I blogged about the TzTime plugin and how I use it in Lighthouse: http://activereload.net/2007/4/13/dealing-with-timezones

For once my timezones work, and I don't have to manage that stuff manually.