【发布时间】:2011-05-19 21:33:14
【问题描述】:
script/console
>> t = Time.at(1158609371)
=> Mon Sep 18 20:56:11 +0100 2006
>> t.zone
=> "BST"
>> s = Shop.find(:first)
>> s.creation_tsz = t.utc
=> Mon Sep 18 19:56:11 UTC 2006
>> s.creation_tsz.zone
=> "UTC"
>> s.save
>> s = Shop.find(:first)
>> s.creation_tsz
=> Sat Jan 01 19:56:11 UTC 2000
它是如何从 2006 年 9 月 18 日更改为 2000 年 1 月 1 日的?时区设置为在 environment.rb 中使用“UTC”。并且您知道我已经尝试了许多行 s.creation_tsz = t.utc 的变体。都以失败告终。
【问题讨论】:
标签: ruby-on-rails ruby datetime activerecord time