3

I'm using Mongoid for my simple Rails 3.x app. I have this model:

class Report

  include Mongoid::Document
  include Mongoid::Timestamps

end

I want to get all Report created today using my current timezone which is +08:00. I tried using this snippet:

Report.where(:created_at => DateTime.now.at_beginning_of_day.utc..Time.now.utc).to_a

However, when I trigger:

DateTime.now.at_beginning_of_day.utc

It gets the date yesterday and the timezone is +00:00

Ben
  • 1,370
  • 17
  • 42

1 Answers1

1

You should probably be calling Report.where(:created_at.gt => ... to get all reports created since the beginning of the day.

Baruch
  • 1,133
  • 10
  • 18