Time.now & Created_at are different? Ruby on Rails

To add onto Roadmaster's answer, I had a similar challenge: the normal Rails timestamps were stored based on UTC in the database, but I needed to query to find all records created today according to the local time zone.

The query looked like this:

completions.where("created_at BETWEEN ? AND ?", 
  Date.today, Date.today + 1.day).count >= 1

I fixed this by calling #to_time on the dates, as follows. This converted them into a timestamp having the proper time zone, and the correct records were fetched in the database, effectively making the query timezone-aware.

completions.where("created_at BETWEEN ? AND ?", 
  Date.today.to_time, Date.today.to_time + 1.day).count >= 1

Rails always stores UTC time on the database; the created_at field by itself should be offset by exactly your timezone's variation relative to UTC.

Whenever you load a record in your application, the fields get converted to the timezone specified in environment.rb. It might have something like this:

config.time_zone = 'UTC'

For the time to be converted properly to your timezone, you might change this configuration setting to one matching your actual time zone. For instance:

config.time_zone = 'Central Time (US & Canada)'

To see available zones, issue "rake -D time" on your rails directory. This will give you instructions on how to get time zone names for use in configuration.