I have a data model that contains a DateTime attribute, date. I want to find out if that date is today. I'm having a hell of a time!
>> Deal.first.date
=> Mon, 14 Dec 2009 23:59:59 EST -05:00
I've tried so many techniques that I would be embarrassed to put them here. So I would just ask, what do I need to match this date in an ActiveRecord find method?
Thanks, Aaron.
I'm guessing the time zone is driving you batty.
For a specific instance, you can do:
model.date.today?
For an activerecord find, try this:
Deal.all(:conditions=>['date > ?',Time.zone.now.beginning_of_day])
Here's the problem:
>> Time.zone.now.beginning_of_day == Date.today.beginning_of_day
=> false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With