Rails 3 convert time of created_at before saving to MySQL

How can I prevent this? This happens even if I do not set config.time_zone

Basically Rails 3 subtract 7 hours from the current time before saving it to MySQL.

I never had this issue in Rails 2.3.5.

How would I disable this functionality?


I understand a little better now. I am in Bangkok time. Rails converts time into UTC before saving it to MySQL.

I do not wish for this behavior. I would rather have created_at stored as Bangkok time as was always the case in Rails 2.3.5.

I never wish for this UTC time.

Further investigation, MySQL is running in ICT (Bangkok Time)

Quoting Sharkie Landshark <lists@ruby-forum.com>:

How can I prevent this? This happens even if I do not set config.time_zone

config.time_zone = 'Bangkok'

or the appropriate value among the output of:

rake time:zones:local

HTH,   Jeffrey

Did you restart your server? Did you properly migrate config/environment.rb to config/application.rb. I.e., change

Rails::Initializer.run do |config|   config.time_zone = 'Bangkok' end


# config/application.rb module YourApplicationName   class Application < Rails::Application     config.time_zone = 'Bangkok'   end end

It sounds you haven't completed the migration completely.


Quoting Sharkie Landshark <lists@ruby-forum.com>:

I did properly migrate to Rails 3. I no longer have Rails::Initializer.run do |config|

Inside class Application < Rails::Application is the only place I have config.time_zone = 'Bangkok'

I restarted a few times as well.


Jeffrey L. Taylor wrote:

I just had the same problem and solved it by either : - modify the datatype of my DB attribute from datetime to date (if tou want to store date) OR - convert your data from date to datetime, by using to_datetime (if you want to store datetime)

Hope it helps


Sharkie Landshark wrote: