【发布时间】:2012-08-18 21:13:22
【问题描述】:
我想将组日期(天 + 小时)转换为用户时区以显示列表,我不想更新数据库。我有几个小组,这段代码非常慢。
# GROUP.RB
# day -> Date
# hour -> Time
# wday -> Integer
.
.
groups.each do |g|
new_day = g.in_gmt_day(user_time_zone) # <-- Concat group.day with group.hour and convert the result day with the user time zone.
g.wday = new_day.wday
g.hour = new_day
end
.
.
谁能帮帮我?
谢谢。
【问题讨论】:
-
是否有机会更改存储空间,以便存储单个
TIMESTAMP WITH TIME ZONE字段,例如2012-01-01 11:00:00 UTC(日期为 2012-01-01,第 11 小时)?它会让一切变得容易得多。
标签: ruby-on-rails-3 postgresql timezone