I'm in Korea.
Rails version is 2.3.5
in my environment,
config.time_zone = 'Seoul'
config.active_record.default_timezone = '开发者_JAVA百科Seoul'
created_at and updated_at value is inserted with local time in database.
but, when I access model.created_at or model.updated_at, the value is understanding with UTC +9:00
So, I insert model to database and get the value, and check difference both values immediately, It is different bellow:
>> Time.now.to_datetime
=> Sun, 24 Jan 2010 21:28:03 +0900
# insert new Product. And check difference Time.now and Product.created_at immediately.
>> Product.last.created_at.to_datetime
=> Mon, 25 Jan 2010 06:12:51 +0900
Is it a bug of rails?
There is a known bug in Rails:
Rails Timezone Gotcha: ActiveRecord::Base.find does not convert Time objects to UTC
http://marklunds.com/articles/one/402
精彩评论