出于某种原因,在开发(我的本地 Mac)和生产(Heroku)中出现了不同的时间。看看:(就在这样做之前,我做了一个heroku db:pull
,所以数据库应该是相同的)
生产(Heroku)
>> Annotation.last.id
=> 2028
>> Annotation.last.created_at
=> Sat, 12 Sep 2009 06:51:33 UTC +00:00
>> Time.zone
=> #<ActiveSupport::TimeZone:0x2b4972a4e2f0 @tzinfo=#<TZInfo::DataTimezone: Etc/UTC>, @utc_offset=0, @name="UTC">
>> Time.now.zone
=> "PDT"
开发(我的 Macbook Pro)
>> Annotation.last.id
=> 2028
>> Annotation.last.created_at
=> Sat, 12 Sep 2009 09:51:33 UTC +00:00
>> Time.zone
=> #<ActiveSupport::TimeZone:0x23c92c0 @tzinfo=#<TZInfo::DataTimezone: Etc/UTC>, @utc_offset=0, @name="UTC">
>> Time.now.zone
=> "EDT"
由于created_at
时间相差 3 小时,我认为这与 EDT 和 PDT 之间的 3 小时差异有关,但我不确定发生了什么。
编辑:这是原始数据的样子:
sqlite> Select created_at from annotations where id = 2028;
2009-09-12T09:51:33-04:00