all my date ties are stored with the standard :db format and being in
western Europe, I have an UTC offset +1
> Time.now.at_beginning_of_day
=> 2012-02-07 00:00:00 +0100
I'ld like to know if I am right ( or wrong) in my date time based
queries like :
scope :today, lambda {
where("created_at >= ? AND created_at < ? ",
Time.now.at_beginning_of_day, Time.now.tomorrow.at_beginning_of_day)
}
which generates:
SELECT `event_logs`.* FROM `event_logs` WHERE (created_at >=
'2012-02-06 23:00:00' AND < '2012-02-07 23:00:00' )
--------------
OR should I use the Time.now.utc to cope with the :db format ?
scope :today, lambda {
where("created_at >= ? AND created_at < ? ",
Time.now.utc.at_beginning_of_day,
Time.now.utc.tomorrow.at_beginning_of_day)
}
which generates:
SELECT `event_logs`.* FROM `event_logs` WHERE (created_at >=
'2012-02-07 00:00:00' AND created_at < '2012-02-08 00:00:00' )
my guess is the 2nd scope , but I am not sure
thanks for your feedback
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.