Rails 时区问题
这是我的控制台:
irb(main):048:0> Time.now
=> 2011-04-13 00:51:50 +0200
<c => (@stats[5] == '-' ? 0 : @stats[3]), :earn => @stats[6])
=> #<Reklamer id: 75, virksomhed: "Orville", dato: "2011-04-13 00:00:00", unik_k
lik: 0, klik: 0, unik_vis: 0, vis: 0, leads: 0, ordre: 0, earn: 0, created_at: "
2011-04-12 22:52:13", updated_at: "2011-04-12 22:52:13", cpc: 0>
irb(main):050:0>
正如您所看到的,当我创建新项目时,updated_at 和created_at 是“2011-04-12 22:52:13”而不是正确的时间:2011-04-13 00:51:50
Here is my console:
irb(main):048:0> Time.now
=> 2011-04-13 00:51:50 +0200
<c => (@stats[5] == '-' ? 0 : @stats[3]), :earn => @stats[6])
=> #<Reklamer id: 75, virksomhed: "Orville", dato: "2011-04-13 00:00:00", unik_k
lik: 0, klik: 0, unik_vis: 0, vis: 0, leads: 0, ordre: 0, earn: 0, created_at: "
2011-04-12 22:52:13", updated_at: "2011-04-12 22:52:13", cpc: 0>
irb(main):050:0>
As you can see when I create a new item updated_at and created_at is "2011-04-12 22:52:13" instead of the correct time: 2011-04-13 00:51:50
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rails 默认存储在 +0000 时区,而您当前的时区是 +0200
相关主题:
UPD
用于理解。如果设置
config.time_zone = 'Copenhagen'
是什么意思?UTC +0000
示例 (
config.time_zone = 'Moscow' # +0400
)为什么它以 +0000 UTC 存储时间?由于用户可以选择任何本地时区,因此它会自动偏移到用户时区。
Rails stores at +0000 Time zone by default, while your current time zone is +0200
Related topics:
UPD
For understanding. If you set
config.time_zone = 'Copenhagen'
what does it mean?UTC +0000
Example (
config.time_zone = 'Moscow' # +0400
)Why does it store Time in +0000 UTC? Because user can choose any local time zone, so it will automaticaly offseted to users time zone.