【问题标题】:Is there timezone offset bug in ruby on rails?ruby on rails 中是否存在时区偏移错误?
【发布时间】:2010-01-24 12:31:01
【问题描述】:

我在韩国。

Rails 版本是 2.3.5

在我的环境中,

  config.time_zone = 'Seoul'
  config.active_record.default_timezone = 'Seoul'

created_at 和 updated_at 值与本地时间一起插入到数据库中。

但是,当我访问 model.created_at 或 model.updated_at 时, 价值是理解 UTC +9:00

所以,我将模型插入数据库并获取值,并立即检查两个值的差异, 不同的是:

>> 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

是不是rails的bug?

【问题讨论】:

    标签: ruby-on-rails ruby timezone


    【解决方案1】:

    Rails 中有一个已知错误:

    Rails 时区问题:ActiveRecord::Base.find 不会将 Time 对象转换为 UTC

    http://marklunds.com/articles/one/402

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 2012-11-07
      • 2015-09-09
      • 2011-04-29
      • 1970-01-01
      相关资源
      最近更新 更多