0
我拉小时数据,缓存它,然后在javascript滚动条中使用该数据。无论如何。这是主要问题。我使用的是:在rails中的时区真的让我感到困惑
config.time_zone = 'Eastern Time (US & Canada)'
好看起来很好,当我做:
Entry.first.created_at #datetime -0500
看起来不错,但它不是当我使用以下范围
scope :hourly, lambda {|h|
g = DateTime.current.beginning_of_day + h.hours
where(created_at: g..g+1.hours)
}
scope :hourly_by_date, lambda {|h,date|
g = DateTime.parse(date + " 00:00:00 Eastern Time (US & Canada)") + h.hours
where(created_at: g..g+1.hours)
}
scope :hours_ago, lambda {|h|
g = DateTime.current.beginning_of_hour - h.hours
where(created_at: g..g+1.hours)
}
它显示的东西,说它是在午夜之前/之后创建的,当时我在下午6:06创建了该记录(-0700) 这超出了沮丧,我可以使用一些指导。
谢谢。
请勿张贴生气。它只是让你看起来像一只鹅:-) – paxdiablo
如果你改变'y.hours.since(x)'而不是'x + y.hours'(无论你有什么'x + y.hours'),它会起作用吗? AFAIK,'+'不会做时区,'#自''。我可能是错的... – Amadan
问题不在于我的+时间不起作用,而是。但是当生成sql查询时,与使用UTC的数据库相比,它使用错误的日期/时间。 –