(なお、UTCの6/30 15:00 = JSTの7/1 0:00) のようなデータがあるとする。「日本時間で7/1/2014 0:00以降に作成されたものを拾う」(つまり、b,c,dを拾う)には以下のどれが正しいか? Item.where("timestamp >= ?", Time.new(2014,7,1)) Item.where("timestamp >= ?", Date.new(2014,7,1)) Item.where("timestamp >= ?", DateTime.new(2014,7,1)) 正解 1のみ。 解説 それぞれ発生させるクエリは以下です。 SELECT `items`.* FROM `items` WHERE (timestamp >= '2014-06-30 15:00:00') SELECT `items`.* FROM `items` WHERE
![Railsのタイムゾーンの闇(1) 比較クエリにはちゃんとタイムゾーンのついた値を渡そう - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/1b1348d971b4e3d03bbad4c4bf28db8ae1868760/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Fogp-background-1150d8b18a7c15795b701a55ae908f94.png%3Fixlib%3Drb-1.2.2%26w%3D1200%26mark%3Dhttps%253A%252F%252Fqiita-user-contents.imgix.net%252F~text%253Fixlib%253Drb-1.2.2%2526w%253D840%2526h%253D380%2526txt%253DRails%2525E3%252581%2525AE%2525E3%252582%2525BF%2525E3%252582%2525A4%2525E3%252583%2525A0%2525E3%252582%2525BE%2525E3%252583%2525BC%2525E3%252583%2525B3%2525E3%252581%2525AE%2525E9%252597%252587%2525281%252529%252520%2525E6%2525AF%252594%2525E8%2525BC%252583%2525E3%252582%2525AF%2525E3%252582%2525A8%2525E3%252583%2525AA%2525E3%252581%2525AB%2525E3%252581%2525AF%2525E3%252581%2525A1%2525E3%252582%252583%2525E3%252582%252593%2525E3%252581%2525A8%2525E3%252582%2525BF%2525E3%252582%2525A4%2525E3%252583%2525A0%2525E3%252582%2525BE%2525E3%252583%2525BC%2525E3%252583%2525B3%2525E3%252581%2525AE%2525E3%252581%2525A4%2525E3%252581%252584%2525E3%252581%25259F%2525E5%252580%2525A4%2525E3%252582%252592%2525E6%2525B8%2525A1%2525E3%252581%25259D%2525E3%252581%252586%2526txt-color%253D%252523333%2526txt-font%253DAvenir-Black%2526txt-size%253D54%2526txt-clip%253Dellipsis%2526txt-align%253Dcenter%25252Cmiddle%2526s%253D90e1bcd64daffa2d55fc9e9c297ab45a%26mark-align%3Dcenter%252Cmiddle%26blend%3Dhttps%253A%252F%252Fqiita-user-contents.imgix.net%252F~text%253Fixlib%253Drb-1.2.2%2526w%253D840%2526h%253D500%2526txt%253D%252540sylph01%2526txt-color%253D%252523333%2526txt-font%253DAvenir-Black%2526txt-size%253D45%2526txt-align%253Dright%25252Cbottom%2526s%253D0350690455602a7157d055661c78a7b2%26blend-align%3Dcenter%252Cmiddle%26blend-mode%3Dnormal%26s%3D638744aa0dffb78bb8e26413e07876f1)