运行环境 Rails 2.3.8 Ruby 1.8.7 Linux
>> a = Activity.last
=> #<Activity id: 247, name: "而让人", stime: "2012-05-29 15:20", circle_id: 1, created_at: "2012-05-29 15:24", updated_at: "2012-05-29 15:24", user_id: 5, comments_count: 0, status: 0, stop_time: nil, user_count: 0>
>> a.stime
=> Tue May 29 15:20:00 UTC 2012
>> i = a.stime.to_i
=> 1338304800
>> Time.at(i)
=> Tue May 29 23:20:00 +0800 2012
如上,是我在 console 中运行的代码 同一个时间,相互转换后的时间怎么会不一样呢? 如下是我的配置文件
config.time_zone = 'Beijing'
config.active_record.default_timezone = :local
config.active_record.time_zone_aware_attributes = false # this is important!